@@ -2243,14 +2243,31 @@ test_count_read_concern_live (void *unused)
2243
2243
collection = mongoc_client_get_collection (client , "test" , "test" );
2244
2244
ASSERT (collection );
2245
2245
2246
- /* don't care if ns not found. */
2247
- (void ) mongoc_collection_drop (collection , & error );
2246
+ // Drop collection.
2247
+ // Use writeConcern=majority so later readConcern=majority observes dropped
2248
+ // collection.
2249
+ {
2250
+ mongoc_write_concern_t * wc = mongoc_write_concern_new ();
2251
+ mongoc_write_concern_set_w (wc , MONGOC_WRITE_CONCERN_W_MAJORITY );
2252
+ bson_t drop_opts = BSON_INITIALIZER ;
2253
+ mongoc_write_concern_append (wc , & drop_opts );
2254
+ if (!mongoc_collection_drop_with_opts (collection , & drop_opts , & error )) {
2255
+ // Ignore an "ns not found" error.
2256
+ if (NULL == strstr (error .message , "ns not found" )) {
2257
+ ASSERT_OR_PRINT (false, error );
2258
+ }
2259
+ }
2260
+
2261
+ bson_destroy (& drop_opts );
2262
+ mongoc_write_concern_destroy (wc );
2263
+ }
2248
2264
2249
2265
bson_init (& b );
2250
2266
count = mongoc_collection_count (
2251
2267
collection , MONGOC_QUERY_NONE , & b , 0 , 0 , NULL , & error );
2252
2268
bson_destroy (& b );
2253
- ASSERT_OR_PRINT (count == 0 , error );
2269
+ ASSERT_OR_PRINT (count != -1 , error );
2270
+ ASSERT_CMPINT64 (count , = = , 0 );
2254
2271
2255
2272
/* Setting readConcern to NULL should not send readConcern */
2256
2273
rc = mongoc_read_concern_new ();
@@ -2261,7 +2278,8 @@ test_count_read_concern_live (void *unused)
2261
2278
count = mongoc_collection_count (
2262
2279
collection , MONGOC_QUERY_NONE , & b , 0 , 0 , NULL , & error );
2263
2280
bson_destroy (& b );
2264
- ASSERT_OR_PRINT (count == 0 , error );
2281
+ ASSERT_OR_PRINT (count != -1 , error );
2282
+ ASSERT_CMPINT64 (count , = = , 0 );
2265
2283
mongoc_read_concern_destroy (rc );
2266
2284
2267
2285
/* readConcern: { level: local } should raise error pre 3.2 */
@@ -2273,7 +2291,8 @@ test_count_read_concern_live (void *unused)
2273
2291
count = mongoc_collection_count (
2274
2292
collection , MONGOC_QUERY_NONE , & b , 0 , 0 , NULL , & error );
2275
2293
bson_destroy (& b );
2276
- ASSERT_OR_PRINT (count == 0 , error );
2294
+ ASSERT_OR_PRINT (count != -1 , error );
2295
+ ASSERT_CMPINT64 (count , = = , 0 );
2277
2296
mongoc_read_concern_destroy (rc );
2278
2297
2279
2298
/* readConcern: { level: majority } should raise error pre 3.2 */
@@ -2285,7 +2304,8 @@ test_count_read_concern_live (void *unused)
2285
2304
count = mongoc_collection_count (
2286
2305
collection , MONGOC_QUERY_NONE , & b , 0 , 0 , NULL , & error );
2287
2306
bson_destroy (& b );
2288
- ASSERT_OR_PRINT (count == 0 , error );
2307
+ ASSERT_OR_PRINT (count != -1 , error );
2308
+ ASSERT_CMPINT64 (count , = = , 0 );
2289
2309
mongoc_read_concern_destroy (rc );
2290
2310
2291
2311
mongoc_collection_destroy (collection );
0 commit comments