diff --git a/mongoDB.cabal b/mongoDB.cabal index 988920a..16a6b54 100644 --- a/mongoDB.cabal +++ b/mongoDB.cabal @@ -14,13 +14,14 @@ Maintainer: Fedor Gogolev Copyright: Copyright (c) 2010-2012 10gen Inc. License: OtherLicense License-file: LICENSE -Cabal-version: >= 1.6 +Cabal-version: >= 1.10 Build-type: Simple Stability: alpha Library GHC-options: -Wall GHC-prof-options: -auto-all + default-language: Haskell2010 Build-depends: array -any , base <5 @@ -51,3 +52,18 @@ Library Source-repository head Type: git Location: https://github.com/mongodb-haskell/mongodb + +test-suite test + hs-source-dirs: test + main-is: main.hs + ghc-options: -Wall + type: exitcode-stdio-1.0 + + build-depends: mongoDB + , base + , mtl + , hspec + + default-language: Haskell2010 + default-extensions: OverloadedStrings + diff --git a/test/QueryTest.hs b/test/QueryTest.hs new file mode 100644 index 0000000..e957232 --- /dev/null +++ b/test/QueryTest.hs @@ -0,0 +1,14 @@ +module QueryTest (querySpec) where +import TestImport + +fakeDB :: MonadIO m => Action m a -> m a +fakeDB = access (error "Pipe") (error "AccessMode") "fake" + +querySpec :: Spec +querySpec = + describe "useDb" $ + it "changes the db" $ do + db1 <- fakeDB thisDatabase + db1 `shouldBe` "fake" + db2 <- fakeDB $ useDb "use" thisDatabase + db2 `shouldBe` "use" diff --git a/test/TestImport.hs b/test/TestImport.hs new file mode 100644 index 0000000..9b99618 --- /dev/null +++ b/test/TestImport.hs @@ -0,0 +1,7 @@ +module TestImport ( + module Export +) where + +import Test.Hspec as Export hiding (Selector) +import Database.MongoDB as Export +import Control.Monad.Trans as Export (MonadIO, liftIO) diff --git a/test/main.hs b/test/main.hs new file mode 100644 index 0000000..5e74cec --- /dev/null +++ b/test/main.hs @@ -0,0 +1,8 @@ +module Main where +import Test.Hspec (hspec) + +import QueryTest + +main :: IO () +main = hspec $ do + querySpec