Skip to content

Commit 270c54f

Browse files
authored
remove batchSize and limit from isMaster (#750)
1 parent 26898e5 commit 270c54f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/libmongoc/tests/test-mongoc-cursor.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444

4545
typedef mongoc_cursor_t *(*make_cursor_fn) (mongoc_collection_t *);
4646

47+
static mongoc_cursor_t *
48+
_make_cmd_deprecated_cursor (mongoc_collection_t *coll);
49+
4750
static mongoc_cursor_t *
4851
_make_array_cursor (mongoc_collection_t *coll);
4952

@@ -150,16 +153,17 @@ _test_common_clone_w_concerns (void *ctx)
150153
mongoc_read_concern_destroy (cursor->read_concern);
151154
cursor->read_concern = read_concern;
152155
/* 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. */
155158
cloned = mongoc_cursor_clone (cursor);
156159
/* test cloned read_concern. */
157160
ASSERT (!mongoc_read_concern_is_default (cloned->read_concern));
158161
ASSERT_CMPSTR (mongoc_read_concern_get_level (cloned->read_concern),
159162
MONGOC_READ_CONCERN_LEVEL_LOCAL);
160163
/* test cloned write_concern. */
161164
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);
163167
ASSERT (mongoc_write_concern_get_w (cloned->write_concern) ==
164168
MONGOC_WRITE_CONCERN_W_MAJORITY);
165169
/* check generated bson in cloned cursor. */
@@ -305,8 +309,9 @@ _test_common_opts (void *ctx)
305309
BSON_ASSERT (mongoc_cursor_set_hint (cursor, sd->id));
306310
ASSERT_CMPINT (mongoc_cursor_get_hint (cursor), ==, sd->id);
307311

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) {
310315
mongoc_cursor_set_batch_size (cursor, 1);
311316
ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 1);
312317
BSON_ASSERT (mongoc_cursor_set_limit (cursor, 2));
@@ -316,10 +321,11 @@ _test_common_opts (void *ctx)
316321
mongoc_cursor_set_max_await_time_ms (cursor, 3);
317322
ASSERT_CMPINT (mongoc_cursor_get_max_await_time_ms (cursor), ==, 3);
318323
/* prime the cursor. */
319-
BSON_ASSERT (mongoc_cursor_next (cursor, &doc));
324+
ASSERT_OR_PRINT (mongoc_cursor_next (cursor, &doc), cursor->error);
320325
/* options should be unchanged. */
321326
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) {
323329
ASSERT_CMPINT (mongoc_cursor_get_batch_size (cursor), ==, 1);
324330
ASSERT_CMPINT ((int) mongoc_cursor_get_limit (cursor), ==, 2);
325331
/* limit cannot be set again. */

0 commit comments

Comments
 (0)