From 0038e4163ce0a28ecef3ca09f449b2b55056dffa Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sat, 20 Jun 2015 21:10:35 -0700 Subject: [PATCH] Add big test --- mongoDB.cabal | 1 + test/QuerySpec.hs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/mongoDB.cabal b/mongoDB.cabal index 481df2d..441cd58 100644 --- a/mongoDB.cabal +++ b/mongoDB.cabal @@ -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 diff --git a/test/QuerySpec.hs b/test/QuerySpec.hs index 8c5f93c..510d408 100644 --- a/test/QuerySpec.hs +++ b/test/QuerySpec.hs @@ -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"]]