Fix tests
This commit is contained in:
parent
a828806940
commit
139a17248f
2 changed files with 9 additions and 4 deletions
|
@ -449,10 +449,11 @@ insertCommandDocument opts col docs writeConcern =
|
||||||
]
|
]
|
||||||
|
|
||||||
takeRightsUpToLeft :: [Either a b] -> [b]
|
takeRightsUpToLeft :: [Either a b] -> [b]
|
||||||
takeRightsUpToLeft l = go l []
|
takeRightsUpToLeft l = reverse $ go l []
|
||||||
where
|
where
|
||||||
|
go [] !res = res
|
||||||
go ((Right x):xs) !res = go xs (x:res)
|
go ((Right x):xs) !res = go xs (x:res)
|
||||||
go ((Left x):xs) !res = res
|
go ((Left _):_) !res = res
|
||||||
|
|
||||||
insert' :: (MonadIO m)
|
insert' :: (MonadIO m)
|
||||||
=> [InsertOption] -> Collection -> [Document] -> Action m [Value]
|
=> [InsertOption] -> Collection -> [Document] -> Action m [Value]
|
||||||
|
@ -479,6 +480,10 @@ insert' opts col docs = do
|
||||||
else rights preChunks
|
else rights preChunks
|
||||||
|
|
||||||
chunkResults <- forM chunks (insertBlock opts col)
|
chunkResults <- forM chunks (insertBlock opts col)
|
||||||
|
|
||||||
|
let lchunks = lefts preChunks
|
||||||
|
when ((not $ null lchunks) && ordered) $ do
|
||||||
|
liftIO $ throwIO $ head lchunks
|
||||||
return $ concat chunkResults
|
return $ concat chunkResults
|
||||||
|
|
||||||
insertBlock :: (MonadIO m)
|
insertBlock :: (MonadIO m)
|
||||||
|
|
|
@ -110,8 +110,8 @@ spec = around withCleanDatabase $ do
|
||||||
describe "insertAll" $ do
|
describe "insertAll" $ do
|
||||||
it "inserts documents to the collection and returns their _ids" $ do
|
it "inserts documents to the collection and returns their _ids" $ do
|
||||||
(_id1:_id2:_) <- db $ insertAll "team" [ ["name" =: "Yankees", "league" =: "American"]
|
(_id1:_id2:_) <- db $ insertAll "team" [ ["name" =: "Yankees", "league" =: "American"]
|
||||||
, ["name" =: "Dodgers", "league" =: "American"]
|
, ["name" =: "Dodgers", "league" =: "American"]
|
||||||
]
|
]
|
||||||
result <- db $ rest =<< find (select [] "team")
|
result <- db $ rest =<< find (select [] "team")
|
||||||
result `shouldBe` [["_id" =: _id1, "name" =: "Yankees", "league" =: "American"]
|
result `shouldBe` [["_id" =: _id1, "name" =: "Yankees", "league" =: "American"]
|
||||||
,["_id" =: _id2, "name" =: "Dodgers", "league" =: "American"]
|
,["_id" =: _id2, "name" =: "Dodgers", "league" =: "American"]
|
||||||
|
|
Loading…
Reference in a new issue