Skip to content

Commit f1c276f

Browse files
authored
Use majority concern for tailable cursor tests (#1380)
1 parent a50c2f6 commit f1c276f

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Diff for: src/mongocxx/test/collection.cpp

+19-5
Original file line numberDiff line numberDiff line change
@@ -2340,12 +2340,26 @@ TEST_CASE("Cursor iteration", "[collection][cursor]") {
23402340
client mongodb_client{uri{}, test_util::add_test_server_api()};
23412341
database db = mongodb_client["collection_cursor_iteration"];
23422342

2343-
auto capped_name = std::string("mongo_cxx_driver_capped");
2344-
collection coll = db[capped_name];
2343+
// Drop and (re)create the capped collection with majority concern.
2344+
collection coll = [&db] {
2345+
write_concern wc_majority;
2346+
wc_majority.acknowledge_level(write_concern::level::k_majority);
23452347

2346-
// Drop and (re)create the capped collection.
2347-
coll.drop();
2348-
db.create_collection(capped_name, make_document(kvp("capped", true), kvp("size", 1024 * 1024)));
2348+
read_concern rc_majority;
2349+
rc_majority.acknowledge_level(read_concern::level::k_majority);
2350+
2351+
auto const capped_name = bsoncxx::stdx::string_view{"mongo_cxx_driver_capped"};
2352+
2353+
auto ret = db[capped_name];
2354+
2355+
ret.drop();
2356+
ret = db.create_collection(capped_name, make_document(kvp("capped", true), kvp("size", 1024 * 1024)));
2357+
2358+
ret.write_concern(wc_majority);
2359+
ret.read_concern(rc_majority);
2360+
2361+
return ret;
2362+
}();
23492363

23502364
// Tests will use all three cursor types.
23512365
options::find opts;

0 commit comments

Comments
 (0)