44
44
45
45
typedef mongoc_cursor_t * (* make_cursor_fn ) (mongoc_collection_t * );
46
46
47
+ static mongoc_cursor_t *
48
+ _make_cmd_deprecated_cursor (mongoc_collection_t * coll );
49
+
47
50
static mongoc_cursor_t *
48
51
_make_array_cursor (mongoc_collection_t * coll );
49
52
@@ -150,16 +153,17 @@ _test_common_clone_w_concerns (void *ctx)
150
153
mongoc_read_concern_destroy (cursor -> read_concern );
151
154
cursor -> read_concern = read_concern ;
152
155
/* don't call mongoc_cursor_next (), since the test may run against a version
153
- * of MongoDB that doesn't support read/write concerns, and we are only
154
- * interested in testing if the clone process works. */
156
+ * of MongoDB that doesn't support read/write concerns, and we are only
157
+ * interested in testing if the clone process works. */
155
158
cloned = mongoc_cursor_clone (cursor );
156
159
/* test cloned read_concern. */
157
160
ASSERT (!mongoc_read_concern_is_default (cloned -> read_concern ));
158
161
ASSERT_CMPSTR (mongoc_read_concern_get_level (cloned -> read_concern ),
159
162
MONGOC_READ_CONCERN_LEVEL_LOCAL );
160
163
/* test cloned write_concern. */
161
164
ASSERT (mongoc_write_concern_get_wmajority (cloned -> write_concern ));
162
- ASSERT (mongoc_write_concern_get_wtimeout_int64 (cloned -> write_concern ) == 1000 );
165
+ ASSERT (mongoc_write_concern_get_wtimeout_int64 (cloned -> write_concern ) ==
166
+ 1000 );
163
167
ASSERT (mongoc_write_concern_get_w (cloned -> write_concern ) ==
164
168
MONGOC_WRITE_CONCERN_W_MAJORITY );
165
169
/* check generated bson in cloned cursor. */
@@ -305,8 +309,9 @@ _test_common_opts (void *ctx)
305
309
BSON_ASSERT (mongoc_cursor_set_hint (cursor , sd -> id ));
306
310
ASSERT_CMPINT (mongoc_cursor_get_hint (cursor ), = = , sd -> id );
307
311
308
- /* listDatabases prohibits limit and batchSize */
309
- if ((make_cursor_fn ) ctx != _make_array_cursor ) {
312
+ /* listDatabases and isMaster prohibits limit and batchSize */
313
+ if ((make_cursor_fn ) ctx != _make_array_cursor &&
314
+ (make_cursor_fn ) ctx != _make_cmd_deprecated_cursor ) {
310
315
mongoc_cursor_set_batch_size (cursor , 1 );
311
316
ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor ), = = , 1 );
312
317
BSON_ASSERT (mongoc_cursor_set_limit (cursor , 2 ));
@@ -316,10 +321,11 @@ _test_common_opts (void *ctx)
316
321
mongoc_cursor_set_max_await_time_ms (cursor , 3 );
317
322
ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor ), = = , 3 );
318
323
/* prime the cursor. */
319
- BSON_ASSERT (mongoc_cursor_next (cursor , & doc ));
324
+ ASSERT_OR_PRINT (mongoc_cursor_next (cursor , & doc ), cursor -> error );
320
325
/* options should be unchanged. */
321
326
ASSERT_CMPINT (mongoc_cursor_get_hint (cursor ), = = , sd -> id );
322
- if ((make_cursor_fn ) ctx != _make_array_cursor ) {
327
+ if ((make_cursor_fn ) ctx != _make_array_cursor &&
328
+ (make_cursor_fn ) ctx != _make_cmd_deprecated_cursor ) {
323
329
ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor ), = = , 1 );
324
330
ASSERT_CMPINT ((int ) mongoc_cursor_get_limit (cursor ), = = , 2 );
325
331
/* limit cannot be set again. */
0 commit comments