Skip to content

Commit b73917a

Browse files
author
Arjun Guha
committed
testing framework
1 parent 5fef52b commit b73917a

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Setup.lhs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/usr/bin/env runhaskell
22
> import Distribution.Simple
3-
> import qualified Data.List as L
4-
> import System.Directory
3+
> import System.Directory (setCurrentDirectory)
54
> import System.Process (runCommand,waitForProcess)
65

76

8-
> main = defaultMainWithHooks simpleUserHooks
7+
> main = defaultMainWithHooks simpleUserHooks { runTests = tests }
8+
9+
> tests _ _ _ _ = do
10+
> setCurrentDirectory "src"
11+
> h <- runCommand "/usr/bin/env runhaskell Database.CouchDB.Tests"
12+
> waitForProcess h
13+
> return ()

src/Database/CouchDB/Tests.hs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module Database.CouchDB.Tests where
2+
3+
import Test.HUnit
4+
import Database.CouchDB
5+
6+
assertDBEqual :: (Eq a, Show a) => String -> a -> CouchMonad a -> Assertion
7+
assertDBEqual msg v m = do
8+
v' <- runCouchDB' m
9+
assertEqual msg v' v
10+
11+
testCreate = TestCase $ assertDBEqual "create/drop database" True $ do
12+
createDB "test1"
13+
dropDB "test1" -- returns True since the database exists.
14+
15+
allTests = TestList [ testCreate ]
16+
17+
main = do
18+
putStrLn "Running CouchDB test suite..."
19+
runTestTT allTests
20+
putStrLn "Testing complete."
21+
return ()

0 commit comments

Comments
 (0)