mirror of
https://github.com/ilyakooo0/roboservant.git
synced 2024-09-11 08:05:47 +03:00
doco
This commit is contained in:
parent
18ca0a21ff
commit
3deefd6139
18
EXAMPLE.md
18
EXAMPLE.md
@ -45,16 +45,14 @@ server introduce = introduce :<|> combine :<|> eliminate
|
|||||||
| otherwise = pure ()
|
| otherwise = pure ()
|
||||||
```
|
```
|
||||||
|
|
||||||
Our tests would usually be in a separate file:
|
In the test file, we first define the configuration:
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
|
|
||||||
|
|
||||||
defaultConfig :: Config
|
defaultConfig :: Config
|
||||||
defaultConfig = Config {
|
defaultConfig = Config {
|
||||||
-- you can pass extra values in using the seed argument. This can be useful
|
-- you can pass extra values in using the seed argument. This can be useful
|
||||||
-- for things that might not be produceable within the api, like auth tokens.
|
-- for things that might not be produceable within the api, like auth tokens.
|
||||||
seed = []
|
seed = [hashedDyn "blah"]
|
||||||
, maxRuntime = 0.5
|
, maxRuntime = 0.5
|
||||||
-- if we get to 1000 interactions with the api, call it quits.
|
-- if we get to 1000 interactions with the api, call it quits.
|
||||||
, maxReps = 1000
|
, maxReps = 1000
|
||||||
@ -65,6 +63,11 @@ defaultConfig = Config {
|
|||||||
, coverageThreshold = 0
|
, coverageThreshold = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
and the tests: the faulty server should fail and the good server should pass.
|
||||||
|
|
||||||
|
```haskell
|
||||||
spec = describe "example" $ do
|
spec = describe "example" $ do
|
||||||
it "good server should not fail" $ do
|
it "good server should not fail" $ do
|
||||||
fuzz @Api goodServer defaultConfig { coverageThreshold = 0.99 } (pure ())
|
fuzz @Api goodServer defaultConfig { coverageThreshold = 0.99 } (pure ())
|
||||||
@ -91,14 +94,13 @@ build it up from components.
|
|||||||
```haskell
|
```haskell
|
||||||
deriving via (Compound B) instance BuildFrom B
|
deriving via (Compound B) instance BuildFrom B
|
||||||
deriving via (Atom B) instance Breakdown B
|
deriving via (Atom B) instance Breakdown B
|
||||||
|
|
||||||
|
|
||||||
main = hspec spec
|
|
||||||
```
|
```
|
||||||
|
|
||||||
finally some uninteresting utilities
|
finally some uninteresting utilities and the entrypoint
|
||||||
|
|
||||||
```haskell
|
```haskell
|
||||||
|
main = hspec spec
|
||||||
|
|
||||||
serverFailure :: Maybe Report -> Bool
|
serverFailure :: Maybe Report -> Bool
|
||||||
serverFailure c = case c of
|
serverFailure c = case c of
|
||||||
Just Report{..} ->
|
Just Report{..} ->
|
||||||
|
Loading…
Reference in New Issue
Block a user