Skip to content

Commit a951fa2

Browse files
committed
Use majority read/write concern for change streams prose test 1
1 parent 2e9c164 commit a951fa2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/mongocxx/test/change_streams.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,15 @@ TEST_CASE("Spec Prose Tests") {
125125
auto coll = db["coll"];
126126
coll.drop();
127127

128+
read_concern rc_majority;
129+
rc_majority.acknowledge_level(read_concern::level::k_majority);
130+
128131
write_concern wc_majority;
129132
wc_majority.majority(std::chrono::seconds(30));
130133

134+
coll.read_concern(rc_majority);
135+
coll.write_concern(wc_majority);
136+
131137
// As a sanity check, we implement the first prose test. The behavior tested
132138
// by the prose tests is implemented and tested by the C driver, so we won't
133139
// replicate the full suite of prose tests here.
@@ -136,28 +142,25 @@ TEST_CASE("Spec Prose Tests") {
136142
// Set the batch size to 1 so we read 1 doc at a time.
137143
options::change_stream opts;
138144
opts.batch_size(1);
139-
auto cs = client.watch(std::move(opts));
145+
auto cs = coll.watch(std::move(opts));
140146

141147
// With WC majority, insert some documents to listen for.
142148
auto doc1 = make_document(kvp("a", 1));
143149
auto doc2 = make_document(kvp("b", 2));
144150
auto doc3 = make_document(kvp("c", 3));
145151

146-
options::insert insert_opts{};
147-
insert_opts.write_concern(wc_majority);
148-
149152
{
150-
auto res = coll.insert_one(doc1.view(), insert_opts);
153+
auto res = coll.insert_one(doc1.view());
151154
REQUIRE(res);
152155
REQUIRE(res->result().inserted_count() == 1);
153156
}
154157
{
155-
auto res = coll.insert_one(doc2.view(), insert_opts);
158+
auto res = coll.insert_one(doc2.view());
156159
REQUIRE(res);
157160
REQUIRE(res->result().inserted_count() == 1);
158161
}
159162
{
160-
auto res = coll.insert_one(doc3.view(), insert_opts);
163+
auto res = coll.insert_one(doc3.view());
161164
REQUIRE(res);
162165
REQUIRE(res->result().inserted_count() == 1);
163166
}

0 commit comments

Comments
 (0)