summaryrefslogtreecommitdiff
path: root/jstests/core/collmod_bad_spec.js
blob: c3d5e7a148ef76e8fbbc27f1dd1274c65d048719 (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
// This is a regression test for SERVER-21545.
//
// Tests that a collMod with a bad specification does not cause any changes, and does not crash the
// server.
//
// @tags: [requires_collmod_command]
(function() {
    "use strict";

    var collName = "collModBadSpec";
    var coll = db.getCollection(collName);

    coll.drop();
    assert.commandWorked(db.createCollection(collName));

    // Get the original collection options for the collection.
    var originalResult = db.getCollectionInfos({name: collName});

    // Issue an invalid command.
    assert.commandFailed(coll.runCommand("collMod", {validationLevel: "off", unknownField: "x"}));

    // Make sure the options are unchanged.
    var newResult = db.getCollectionInfos({name: collName});
    assert.eq(originalResult, newResult);
})();