summaryrefslogtreecommitdiff
path: root/jstests/core/index_id_options.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/core/index_id_options.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/core/index_id_options.js')
-rw-r--r--jstests/core/index_id_options.js107
1 files changed, 52 insertions, 55 deletions
diff --git a/jstests/core/index_id_options.js b/jstests/core/index_id_options.js
index 7f16c7ba8c9..91bdce8090f 100644
--- a/jstests/core/index_id_options.js
+++ b/jstests/core/index_id_options.js
@@ -10,69 +10,66 @@
// - Non-_id indexes cannot have the name "_id_".
(function() {
- "use strict";
+"use strict";
- load("jstests/libs/get_index_helpers.js");
+load("jstests/libs/get_index_helpers.js");
- // Must use local db for testing because autoIndexId:false collections are not allowed in
- // replicated databases.
- var coll = db.getSiblingDB("local").index_id_options;
+// Must use local db for testing because autoIndexId:false collections are not allowed in
+// replicated databases.
+var coll = db.getSiblingDB("local").index_id_options;
- // _id indexes must have key pattern {_id: 1}.
- coll.drop();
- assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
- assert.commandFailed(coll.ensureIndex({_id: -1}, {name: "_id_"}));
+// _id indexes must have key pattern {_id: 1}.
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
+assert.commandFailed(coll.ensureIndex({_id: -1}, {name: "_id_"}));
- // The name of an _id index gets corrected to "_id_".
- coll.drop();
- assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
- assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "bad"}));
- var spec = GetIndexHelpers.findByKeyPattern(coll.getIndexes(), {_id: 1});
- assert.neq(null, spec, "_id index spec not found");
- assert.eq("_id_", spec.name, tojson(spec));
+// The name of an _id index gets corrected to "_id_".
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
+assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "bad"}));
+var spec = GetIndexHelpers.findByKeyPattern(coll.getIndexes(), {_id: 1});
+assert.neq(null, spec, "_id index spec not found");
+assert.eq("_id_", spec.name, tojson(spec));
- // _id indexes cannot have any options other than "key", "name", "ns", "v", and "collation."
- coll.drop();
- assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", unique: true}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", sparse: false}));
- assert.commandFailed(
- coll.ensureIndex({_id: 1}, {name: "_id_", partialFilterExpression: {a: 1}}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", expireAfterSeconds: 3600}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", background: false}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", unknown: true}));
- assert.commandWorked(coll.ensureIndex(
- {_id: 1}, {name: "_id_", ns: coll.getFullName(), v: 2, collation: {locale: "simple"}}));
+// _id indexes cannot have any options other than "key", "name", "ns", "v", and "collation."
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", unique: true}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", sparse: false}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", partialFilterExpression: {a: 1}}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", expireAfterSeconds: 3600}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", background: false}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", unknown: true}));
+assert.commandWorked(coll.ensureIndex(
+ {_id: 1}, {name: "_id_", ns: coll.getFullName(), v: 2, collation: {locale: "simple"}}));
- // _id indexes must have the collection default collation.
- coll.drop();
- assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "en_US"}}));
- assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "simple"}}));
+// _id indexes must have the collection default collation.
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "en_US"}}));
+assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "simple"}}));
- coll.drop();
- assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
- assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "_id_"}));
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
+assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "_id_"}));
- coll.drop();
- assert.commandWorked(
- coll.runCommand("create", {autoIndexId: false, collation: {locale: "en_US"}}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "simple"}}));
- assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "fr_CA"}}));
- assert.commandWorked(
- coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "en_US", strength: 3}}));
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false, collation: {locale: "en_US"}}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "simple"}}));
+assert.commandFailed(coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "fr_CA"}}));
+assert.commandWorked(
+ coll.ensureIndex({_id: 1}, {name: "_id_", collation: {locale: "en_US", strength: 3}}));
- coll.drop();
- assert.commandWorked(
- coll.runCommand("create", {autoIndexId: false, collation: {locale: "en_US"}}));
- assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "_id_"}));
- spec = GetIndexHelpers.findByName(coll.getIndexes(), "_id_");
- assert.neq(null, spec, "_id index spec not found");
- assert.eq("en_US", spec.collation.locale, tojson(spec));
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false, collation: {locale: "en_US"}}));
+assert.commandWorked(coll.ensureIndex({_id: 1}, {name: "_id_"}));
+spec = GetIndexHelpers.findByName(coll.getIndexes(), "_id_");
+assert.neq(null, spec, "_id index spec not found");
+assert.eq("en_US", spec.collation.locale, tojson(spec));
- // Non-_id indexes cannot have the name "_id_".
- coll.drop();
- assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
- assert.commandFailed(coll.ensureIndex({_id: "hashed"}, {name: "_id_"}));
- assert.commandFailed(coll.ensureIndex({a: 1}, {name: "_id_"}));
+// Non-_id indexes cannot have the name "_id_".
+coll.drop();
+assert.commandWorked(coll.runCommand("create", {autoIndexId: false}));
+assert.commandFailed(coll.ensureIndex({_id: "hashed"}, {name: "_id_"}));
+assert.commandFailed(coll.ensureIndex({a: 1}, {name: "_id_"}));
})();