summaryrefslogtreecommitdiff
path: root/jstests/core/find_getmore_cmd.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/core/find_getmore_cmd.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/core/find_getmore_cmd.js')
-rw-r--r--jstests/core/find_getmore_cmd.js143
1 files changed, 70 insertions, 73 deletions
diff --git a/jstests/core/find_getmore_cmd.js b/jstests/core/find_getmore_cmd.js
index 5f815fb1d4c..55ad7a4a443 100644
--- a/jstests/core/find_getmore_cmd.js
+++ b/jstests/core/find_getmore_cmd.js
@@ -2,88 +2,85 @@
// Tests that explicitly invoke the find and getMore commands.
(function() {
- 'use strict';
+'use strict';
- var cmdRes;
- var cursorId;
- var defaultBatchSize = 101;
- var collName = 'find_getmore_cmd';
- var coll = db[collName];
+var cmdRes;
+var cursorId;
+var defaultBatchSize = 101;
+var collName = 'find_getmore_cmd';
+var coll = db[collName];
- coll.drop();
- for (var i = 0; i < 150; i++) {
- assert.writeOK(coll.insert({a: i}));
- }
+coll.drop();
+for (var i = 0; i < 150; i++) {
+ assert.writeOK(coll.insert({a: i}));
+}
- // Verify result of a find command that specifies none of the optional arguments.
- cmdRes = db.runCommand({find: collName});
- assert.commandWorked(cmdRes);
- assert.gt(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.firstBatch.length, defaultBatchSize);
+// Verify result of a find command that specifies none of the optional arguments.
+cmdRes = db.runCommand({find: collName});
+assert.commandWorked(cmdRes);
+assert.gt(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.firstBatch.length, defaultBatchSize);
- // Use a getMore command to get the next batch.
- cursorId = cmdRes.cursor.id;
- cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName});
- assert.commandWorked(cmdRes);
- assert.eq(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.nextBatch.length, 150 - defaultBatchSize);
+// Use a getMore command to get the next batch.
+cursorId = cmdRes.cursor.id;
+cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName});
+assert.commandWorked(cmdRes);
+assert.eq(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.nextBatch.length, 150 - defaultBatchSize);
- // Cursor should have been closed, so attempting to get another batch should fail.
- cmdRes = db.runCommand({getMore: cursorId, collection: collName});
- assert.commandFailed(cmdRes);
+// Cursor should have been closed, so attempting to get another batch should fail.
+cmdRes = db.runCommand({getMore: cursorId, collection: collName});
+assert.commandFailed(cmdRes);
- // Find command with limit.
- cmdRes = db.runCommand({find: collName, limit: 10});
- assert.commandWorked(cmdRes);
- assert.eq(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.firstBatch.length, 10);
+// Find command with limit.
+cmdRes = db.runCommand({find: collName, limit: 10});
+assert.commandWorked(cmdRes);
+assert.eq(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.firstBatch.length, 10);
- // Find command with positive batchSize followed by getMore command with positive batchSize.
- cmdRes = db.runCommand({find: collName, batchSize: 10});
- assert.commandWorked(cmdRes);
- assert.gt(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.firstBatch.length, 10);
- cmdRes =
- db.runCommand({getMore: cmdRes.cursor.id, collection: collName, batchSize: NumberInt(5)});
- assert.gt(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.nextBatch.length, 5);
+// Find command with positive batchSize followed by getMore command with positive batchSize.
+cmdRes = db.runCommand({find: collName, batchSize: 10});
+assert.commandWorked(cmdRes);
+assert.gt(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.firstBatch.length, 10);
+cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, batchSize: NumberInt(5)});
+assert.gt(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.nextBatch.length, 5);
- // Find command with zero batchSize followed by getMore command (default batchSize).
- cmdRes = db.runCommand({find: collName, batchSize: 0});
- assert.commandWorked(cmdRes);
- assert.gt(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.firstBatch.length, 0);
- cmdRes =
- db.runCommand({getMore: cmdRes.cursor.id, collection: collName, batchSize: NumberInt(5)});
- assert.gt(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.nextBatch.length, 5);
+// Find command with zero batchSize followed by getMore command (default batchSize).
+cmdRes = db.runCommand({find: collName, batchSize: 0});
+assert.commandWorked(cmdRes);
+assert.gt(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.firstBatch.length, 0);
+cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, batchSize: NumberInt(5)});
+assert.gt(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.nextBatch.length, 5);
- // Batch size and limit together.
- cmdRes = db.runCommand({find: collName, batchSize: 10, limit: 20});
- assert.commandWorked(cmdRes);
- assert.gt(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.firstBatch.length, 10);
- cmdRes =
- db.runCommand({getMore: cmdRes.cursor.id, collection: collName, batchSize: NumberInt(11)});
- assert.eq(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.nextBatch.length, 10);
+// Batch size and limit together.
+cmdRes = db.runCommand({find: collName, batchSize: 10, limit: 20});
+assert.commandWorked(cmdRes);
+assert.gt(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.firstBatch.length, 10);
+cmdRes = db.runCommand({getMore: cmdRes.cursor.id, collection: collName, batchSize: NumberInt(11)});
+assert.eq(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.nextBatch.length, 10);
- // Find command with batchSize and singleBatch.
- cmdRes = db.runCommand({find: collName, batchSize: 10, singleBatch: true});
- assert.commandWorked(cmdRes);
- assert.eq(cmdRes.cursor.id, NumberLong(0));
- assert.eq(cmdRes.cursor.ns, coll.getFullName());
- assert.eq(cmdRes.cursor.firstBatch.length, 10);
+// Find command with batchSize and singleBatch.
+cmdRes = db.runCommand({find: collName, batchSize: 10, singleBatch: true});
+assert.commandWorked(cmdRes);
+assert.eq(cmdRes.cursor.id, NumberLong(0));
+assert.eq(cmdRes.cursor.ns, coll.getFullName());
+assert.eq(cmdRes.cursor.firstBatch.length, 10);
- // Error on invalid collection name.
- assert.commandFailedWithCode(db.runCommand({find: ""}), ErrorCodes.InvalidNamespace);
+// Error on invalid collection name.
+assert.commandFailedWithCode(db.runCommand({find: ""}), ErrorCodes.InvalidNamespace);
})();