summaryrefslogtreecommitdiff
path: root/jstests/core/list_indexes_invalid.js
blob: 43d64a594c2a761c4921c3d63dd5efe112c72cae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Cannot implicitly shard accessed collections because of collection existing when none
// expected.
// @tags: [assumes_no_implicit_collection_creation_after_drop]

// Test for invalid values of "cursor" and "cursor.batchSize".

var coll = db.list_indexes_invalid;
coll.drop();

assert.commandWorked(coll.getDB().createCollection(coll.getName()));
assert.commandWorked(coll.ensureIndex({a: 1}, {unique: true}));

assert.throws(function() {
    getListIndexesCursor(coll, {cursor: 0});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: 'x'});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: []});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: {foo: 1}});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: {batchSize: -1}});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: {batchSize: 'x'}});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: {batchSize: {}}});
});
assert.throws(function() {
    getListIndexesCursor(coll, {cursor: {batchSize: 2, foo: 1}});
});