Skip to content

Commit 9056f12

Browse files
CXX-799 Update insert_many collection test
1 parent 008862f commit 9056f12

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/mongocxx/test/collection.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,22 @@ TEST_CASE("CRUD functionality", "[driver::collection]") {
229229
REQUIRE(coll.count({}) == 1);
230230
}
231231

232-
// TODO: CXX-799 update this test
233-
// SECTION("matching upsert updates document", "[collection]") {
234-
// bsoncxx::builder::stream::document b1;
235-
// b1 << "x" << 1;
236-
// model::insert_many docs{std::initializer_list<bsoncxx::document::view>{b1, b1, b1}};
237-
// coll.insert_many(docs);
238-
239-
// coll.insert_one(bsoncxx::document::view{});
240-
// REQUIRE(coll.count(b1) == 3);
241-
// REQUIRE(coll.count() == 4);
242-
//}
232+
SECTION("test using an insert_many_builder on this collection", "[collection]") {
233+
auto doc_value = document{} << "x" << 1 << finalize;
234+
auto doc_view = doc_value.view();
235+
236+
insert_many_builder insert_many{options::insert()};
237+
insert_many(doc_view);
238+
insert_many(doc_view);
239+
insert_many(doc_view);
240+
241+
insert_many.insert(&coll);
242+
243+
coll.insert_one(document{} << "b" << 1 << finalize);
244+
245+
REQUIRE(coll.count(doc_view) == 3);
246+
REQUIRE(coll.count({}) == 4);
247+
}
243248

244249
SECTION("document replacement", "[collection]") {
245250
document b1;

0 commit comments

Comments
 (0)