summaryrefslogtreecommitdiff
path: root/jstests/core/list_collections1.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/list_collections1.js')
-rw-r--r--jstests/core/list_collections1.js120
1 files changed, 45 insertions, 75 deletions
diff --git a/jstests/core/list_collections1.js b/jstests/core/list_collections1.js
index 04acb82290b..9745adc1f90 100644
--- a/jstests/core/list_collections1.js
+++ b/jstests/core/list_collections1.js
@@ -46,11 +46,9 @@
assert.commandWorked(mydb.dropDatabase());
assert.commandWorked(mydb.createCollection("foo"));
- assert.eq(1,
- cursorCountMatching(getListCollectionsCursor(),
- function(c) {
- return c.name === "foo";
- }));
+ assert.eq(1, cursorCountMatching(getListCollectionsCursor(), function(c) {
+ return c.name === "foo";
+ }));
//
// Test that the collection metadata object is returned correctly.
@@ -59,16 +57,12 @@
assert.commandWorked(mydb.dropDatabase());
assert.commandWorked(mydb.createCollection("foo"));
assert.commandWorked(mydb.createCollection("bar", {temp: true}));
- assert.eq(1,
- cursorCountMatching(getListCollectionsCursor(),
- function(c) {
- return c.name === "foo" && c.options.temp === undefined;
- }));
- assert.eq(1,
- cursorCountMatching(getListCollectionsCursor(),
- function(c) {
- return c.name === "bar" && c.options.temp === true;
- }));
+ assert.eq(1, cursorCountMatching(getListCollectionsCursor(), function(c) {
+ return c.name === "foo" && c.options.temp === undefined;
+ }));
+ assert.eq(1, cursorCountMatching(getListCollectionsCursor(), function(c) {
+ return c.name === "bar" && c.options.temp === true;
+ }));
//
// Test basic usage of "filter" option.
@@ -77,29 +71,23 @@
assert.commandWorked(mydb.dropDatabase());
assert.commandWorked(mydb.createCollection("foo"));
assert.commandWorked(mydb.createCollection("bar", {temp: true}));
- assert.eq(2,
- cursorCountMatching(getListCollectionsCursor({filter: {}}),
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(getListCollectionsCursor({filter: {}}), function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
assert.eq(2, getListCollectionsCursor({filter: {name: {$in: ["foo", "bar"]}}}).itcount());
assert.eq(1, getListCollectionsCursor({filter: {name: /^foo$/}}).itcount());
assert.eq(1, getListCollectionsCursor({filter: {"options.temp": true}}).itcount());
mydb.foo.drop();
- assert.eq(1,
- cursorCountMatching(getListCollectionsCursor({filter: {}}),
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(1, cursorCountMatching(getListCollectionsCursor({filter: {}}), function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
assert.eq(1, getListCollectionsCursor({filter: {name: {$in: ["foo", "bar"]}}}).itcount());
assert.eq(0, getListCollectionsCursor({filter: {name: /^foo$/}}).itcount());
assert.eq(1, getListCollectionsCursor({filter: {"options.temp": true}}).itcount());
mydb.bar.drop();
- assert.eq(0,
- cursorCountMatching(getListCollectionsCursor({filter: {}}),
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(0, cursorCountMatching(getListCollectionsCursor({filter: {}}), function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
assert.eq(0, getListCollectionsCursor({filter: {name: {$in: ["foo", "bar"]}}}).itcount());
assert.eq(0, getListCollectionsCursor({filter: {name: /^foo$/}}).itcount());
assert.eq(0, getListCollectionsCursor({filter: {"options.temp": true}}).itcount());
@@ -130,50 +118,38 @@
assert.commandWorked(mydb.createCollection("bar"));
cursor = getListCollectionsCursor({cursor: {batchSize: 2}});
assert.eq(2, cursor.objsLeftInBatch());
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
cursor = getListCollectionsCursor({cursor: {batchSize: 1}});
assert.eq(1, cursor.objsLeftInBatch());
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
cursor = getListCollectionsCursor({cursor: {batchSize: 0}});
assert.eq(0, cursor.objsLeftInBatch());
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
cursor = getListCollectionsCursor({cursor: {batchSize: NumberInt(2)}});
assert.eq(2, cursor.objsLeftInBatch());
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
cursor = getListCollectionsCursor({cursor: {batchSize: NumberLong(2)}});
assert.eq(2, cursor.objsLeftInBatch());
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
// Test a large batch size, and assert that at least 2 results are returned in the initial
// batch.
cursor = getListCollectionsCursor({cursor: {batchSize: Math.pow(2, 62)}});
assert.lte(2, cursor.objsLeftInBatch());
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
// Ensure that the server accepts an empty object for "cursor". This is equivalent to not
// specifying "cursor" at all.
@@ -181,11 +157,9 @@
// We do not test for objsLeftInBatch() here, since the default batch size for this command
// is not specified.
cursor = getListCollectionsCursor({cursor: {}});
- assert.eq(2,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo" || c.name === "bar";
- }));
+ assert.eq(2, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo" || c.name === "bar";
+ }));
//
// Test for invalid values of "cursor" and "cursor.batchSize".
@@ -245,11 +219,9 @@
assert.commandWorked(mydb.dropDatabase());
cursor = getListCollectionsCursor();
- assert.eq(0,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo";
- }));
+ assert.eq(0, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo";
+ }));
//
// Test on empty database.
@@ -259,11 +231,9 @@
assert.commandWorked(mydb.createCollection("foo"));
mydb.foo.drop();
cursor = getListCollectionsCursor();
- assert.eq(0,
- cursorCountMatching(cursor,
- function(c) {
- return c.name === "foo";
- }));
+ assert.eq(0, cursorCountMatching(cursor, function(c) {
+ return c.name === "foo";
+ }));
//
// Test killCursors against a listCollections cursor.