summaryrefslogtreecommitdiff
path: root/jstests/core/ddl/create_index_same_spec_different_name.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/ddl/create_index_same_spec_different_name.js')
-rw-r--r--jstests/core/ddl/create_index_same_spec_different_name.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/jstests/core/ddl/create_index_same_spec_different_name.js b/jstests/core/ddl/create_index_same_spec_different_name.js
new file mode 100644
index 00000000000..7b08f9f55ca
--- /dev/null
+++ b/jstests/core/ddl/create_index_same_spec_different_name.js
@@ -0,0 +1,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);
+}());