-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSpecIOExample.idr
40 lines (28 loc) · 920 Bytes
/
SpecIOExample.idr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module SpecIOExample
import Specdris.SpecIO
%access private
%default total
startDb : IO ()
startDb = putStrLn "start database ..."
stopDb : IO ()
stopDb = putStrLn "... stoped database"
testData : IO SpecResult -> IO SpecResult
testData resultIO = do putStrLn "insert test data"
result <- resultIO
putStrLn "delete test data"
pure result
record User where
constructor MkUser
id : Nat
name : String
getUser : Nat -> IO User
getUser id = pure (MkUser id "foo")
getUserSpec : SpecTree
getUserSpec = describe "User table" $ do
it "get a user by id" $ do
user <- getUser 0
pure $ do (name user) === "foo"
export
specSuite : IO ()
specSuite = specIO {beforeAll = startDb} {around = testData} {afterAll = stopDb} $ do
getUserSpec