| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Test.Syd.MongoDB
Contents
Synopsis
- goldenBSONDocumentFile :: FilePath -> IO Document -> GoldenTest Document
- pureGoldenBSONDocumentFile :: FilePath -> Document -> GoldenTest Document
- mongoSpec :: TestDefM (MongoServerHandle ': outers) Pipe result -> TestDefM outers inner result
- mongoConnectionSetupFunc :: MongoServerHandle -> SetupFunc Pipe
- data MongoServerHandle = MongoServerHandle {}
- mongoServerSpec :: TestDefM (MongoServerHandle ': outers) inner result -> TestDefM outers inner result
- mongoServerSetupFunc :: SetupFunc MongoServerHandle
- mongoServerSetupFunc' :: Path Abs Dir -> SetupFunc MongoServerHandle
Golden tests
goldenBSONDocumentFile :: FilePath -> IO Document -> GoldenTest Document Source #
Test that the produced Document is the same as what we find in the given golden file.
pureGoldenBSONDocumentFile :: FilePath -> Document -> GoldenTest Document Source #
Test that the given Document is the same as what we find in the given golden file.
Integration tests
mongoSpec :: TestDefM (MongoServerHandle ': outers) Pipe result -> TestDefM outers inner result Source #
Provide access to a real Pipe for each test.
Example usage:
mongoSpec $ do
it "can write and read an example value" $ \pipe -> do
Mongo.access pipe master "example-database" $ do
let collection = "example-collection"
exampleVal = ["hello" =: ("world" :: Text)]
i <- insert collection exampleVal
r <- findOne (select ["_id" =: i] collection)
liftIO $ r `shouldBe` Just (("_id" =: i) : exampleVal)
pure () :: IO ()This function uses mongoServerSpec as well as mongoConnectionSetupFunc to run a mongo server, provide access to it and clean up before the test.
mongoConnectionSetupFunc :: MongoServerHandle -> SetupFunc Pipe Source #
Connect to the given mongo server and clean up beforehand.
data MongoServerHandle Source #
Constructors
| MongoServerHandle | |
mongoServerSpec :: TestDefM (MongoServerHandle ': outers) inner result -> TestDefM outers inner result Source #
Run a mongo server as an external resource
mongoServerSetupFunc :: SetupFunc MongoServerHandle Source #
Set up, and clean up after, a mongo server in a temporary directory.
mongoServerSetupFunc' :: Path Abs Dir -> SetupFunc MongoServerHandle Source #
Set up, and clean up after, a mongo server, in the given directory.