summaryrefslogtreecommitdiff
path: root/jstests/core/list_indexes_non_existent_ns.js
blob: 0e134862c3aba1464595b17fda18257c14d2f009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Test the listIndexes command on non-existent collection.
(function() {
    var dbTest = db.getSiblingDB("list_indexes_non_existent_db");
    assert.commandWorked(dbTest.dropDatabase());

    var coll;

    // Non-existent database
    coll = dbTest.getCollection("list_indexes_non_existent_db");
    assert.commandFailed(coll.runCommand("listIndexes"));

    // Creates the actual database that did not exist till now
    coll.insert({});

    // Non-existent collection
    coll = dbTest.getCollection("list_indexes_non_existent_collection");
    assert.commandFailed(coll.runCommand("listIndexes"));
}());