summaryrefslogtreecommitdiff
path: root/jstests/core/create_index_same_spec_different_name.js
blob: 7b08f9f55ca9fefd9fe20bcf53f88195063d3c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * Ensures that creating an index with the same key but different name returns the
 * 'IndexOptionsConflict' error.
 */
(function() {
'use strict';

const coll = "create_index_same_spec_different_name";
db.coll.drop();

assert.commandWorked(db.runCommand({createIndexes: coll, indexes: [{key: {x: 1}, name: "x_1"}]}));

assert.commandFailedWithCode(
    db.runCommand({createIndexes: coll, indexes: [{key: {x: 1}, name: "x_2"}]}),
    ErrorCodes.IndexOptionsConflict);
}());