summaryrefslogtreecommitdiff
path: root/jstests/core/exhaust.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/exhaust.js')
-rw-r--r--jstests/core/exhaust.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/jstests/core/exhaust.js b/jstests/core/exhaust.js
index 8a59ac54938..4508e7a51e6 100644
--- a/jstests/core/exhaust.js
+++ b/jstests/core/exhaust.js
@@ -71,5 +71,14 @@ assert.eq(
assert.eq(
numDocs - 1,
coll.find().addOption(DBQuery.Option.exhaust).limit(numDocs - 1).batchSize(100).itcount());
+
+// Test that exhaust with negative limit is allowed. A negative limit means "single batch": the
+// server will return just a single batch and then close the cursor, even if the limit has not yet
+// been reached. When the batchSize is not specified explicitly, we expect the default initial batch
+// size of 101 to be used.
+assert.eq(101, coll.find().addOption(DBQuery.Option.exhaust).limit(-numDocs).itcount());
+assert.eq(50,
+ coll.find().addOption(DBQuery.Option.exhaust).limit(-numDocs).batchSize(50).itcount());
+assert.eq(1, coll.find().addOption(DBQuery.Option.exhaust).limit(-1).itcount());
}());
}());