Add big test

This commit is contained in:
Victor Denisov 2015-06-20 21:10:35 -07:00
parent 5e72c8ad61
commit 0038e4163c
2 changed files with 14 additions and 0 deletions

View file

@ -67,6 +67,7 @@ test-suite test
-- now. It's too difficult to support old versions of GHC and
-- the new version of time.
, old-locale
, text
, time
default-language: Haskell2010

View file

@ -5,6 +5,8 @@ module QuerySpec (spec) where
import TestImport
import Control.Exception
import qualified Data.Text as T
testDBName :: Database
testDBName = "mongodb-haskell-test"
@ -122,6 +124,17 @@ spec = around withCleanDatabase $ do
it "raises exception" $
insertDuplicateWith insertAll_ `shouldThrow` anyException
describe "insertAll_" $ do
it "inserts documents and receives 100 000 of them" $ do
let docs = (flip map) [0..200000] $ \i ->
["name" =: (T.pack $ "name " ++ (show i))]
db $ insertAll_ "bigCollection" docs
db $ do
cur <- find $ (select [] "bigCollection") {limit = 100000, batchSize = 100000}
returnedDocs <- rest cur
liftIO $ (length returnedDocs) `shouldBe` 100000
describe "aggregate" $ do
it "aggregates to normalize and sort documents" $ do
db $ insertAll_ "users" [ ["_id" =: "jane", "joined" =: parseDate "2011-03-02", "likes" =: ["golf", "racquetball"]]