summaryrefslogtreecommitdiff
path: root/jstests/core/index/geo/geo_s2validindex.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/index/geo/geo_s2validindex.js')
-rw-r--r--jstests/core/index/geo/geo_s2validindex.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/core/index/geo/geo_s2validindex.js b/jstests/core/index/geo/geo_s2validindex.js
new file mode 100644
index 00000000000..444346def14
--- /dev/null
+++ b/jstests/core/index/geo/geo_s2validindex.js
@@ -0,0 +1,26 @@
+//
+// Tests valid cases for creation of 2dsphere index
+//
+
+var coll = db.getCollection("twodspherevalid");
+
+// Valid index
+coll.drop();
+assert.commandWorked(coll.createIndex({geo: "2dsphere", other: 1}));
+
+// Valid index
+coll.drop();
+assert.commandWorked(coll.createIndex({geo: "2dsphere", other: 1, geo2: "2dsphere"}));
+
+// Invalid index, using hash with 2dsphere
+coll.drop();
+assert.commandFailed(coll.createIndex({geo: "2dsphere", other: "hash"}));
+
+// Invalid index, using 2d with 2dsphere
+coll.drop();
+assert.commandFailed(coll.createIndex({geo: "2dsphere", other: "2d"}));
+
+jsTest.log("Success!");
+
+// Ensure the empty collection is gone, so that small_oplog passes.
+coll.drop();