summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js')
-rw-r--r--jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js50
1 files changed, 25 insertions, 25 deletions
diff --git a/jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js b/jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js
index 3b1f7337133..2526fed9636 100644
--- a/jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js
+++ b/jstests/noPassthroughWithMongod/captrunc_cursor_invalidation.js
@@ -3,35 +3,35 @@
//
// @tags: [requires_capped]
(function() {
- "use strict";
+"use strict";
- const coll = db.captrunc_cursor_invalidation;
- coll.drop();
+const coll = db.captrunc_cursor_invalidation;
+coll.drop();
- // Create a capped collection with four documents.
- assert.commandWorked(db.createCollection(coll.getName(), {capped: true, size: 1024}));
- const numDocs = 4;
- const bulk = coll.initializeUnorderedBulkOp();
- for (let i = 0; i < numDocs; ++i) {
- bulk.insert({_id: i});
- }
- assert.commandWorked(bulk.execute());
+// Create a capped collection with four documents.
+assert.commandWorked(db.createCollection(coll.getName(), {capped: true, size: 1024}));
+const numDocs = 4;
+const bulk = coll.initializeUnorderedBulkOp();
+for (let i = 0; i < numDocs; ++i) {
+ bulk.insert({_id: i});
+}
+assert.commandWorked(bulk.execute());
- // Open a tailable cursor against the capped collection.
- const findRes = assert.commandWorked(db.runCommand({find: coll.getName(), tailable: true}));
- assert.neq(findRes.cursor.id, 0);
- assert.eq(findRes.cursor.ns, coll.getFullName());
- assert.eq(findRes.cursor.firstBatch.length, 4);
- const cursorId = findRes.cursor.id;
+// Open a tailable cursor against the capped collection.
+const findRes = assert.commandWorked(db.runCommand({find: coll.getName(), tailable: true}));
+assert.neq(findRes.cursor.id, 0);
+assert.eq(findRes.cursor.ns, coll.getFullName());
+assert.eq(findRes.cursor.firstBatch.length, 4);
+const cursorId = findRes.cursor.id;
- // Truncate the capped collection so that the cursor's position no longer exists.
- assert.commandWorked(db.runCommand({captrunc: coll.getName(), n: 2}));
+// Truncate the capped collection so that the cursor's position no longer exists.
+assert.commandWorked(db.runCommand({captrunc: coll.getName(), n: 2}));
- // A subsequent getMore should fail with 'CappedPositionLost'.
- assert.commandFailedWithCode(db.runCommand({getMore: cursorId, collection: coll.getName()}),
- ErrorCodes.CappedPositionLost);
+// A subsequent getMore should fail with 'CappedPositionLost'.
+assert.commandFailedWithCode(db.runCommand({getMore: cursorId, collection: coll.getName()}),
+ ErrorCodes.CappedPositionLost);
- // The cursor has now been destroyed, so another getMore should fail with 'CursorNotFound'.
- assert.commandFailedWithCode(db.runCommand({getMore: cursorId, collection: coll.getName()}),
- ErrorCodes.CursorNotFound);
+// The cursor has now been destroyed, so another getMore should fail with 'CursorNotFound'.
+assert.commandFailedWithCode(db.runCommand({getMore: cursorId, collection: coll.getName()}),
+ ErrorCodes.CursorNotFound);
}());