summaryrefslogtreecommitdiff
path: root/jstests/core/geo_near_random1.js
diff options
context:
space:
mode:
authorBrandon Zhang <brandon.zhang@mongodb.com>2015-07-30 13:37:15 -0400
committerBrandon Zhang <brandon.zhang@mongodb.com>2015-08-12 17:51:34 -0400
commit7b88c26458c6ac82469ca4c061f94314f3bd689c (patch)
treea1b1225a5b48ee7009fa34006133a0dd8e1c382d /jstests/core/geo_near_random1.js
parentda780777b278314d7820483882af014b7b773547 (diff)
downloadmongo-7b88c26458c6ac82469ca4c061f94314f3bd689c.tar.gz
CAP-2451 Added distance check and 2dsphere tests to tests involving GeoNearRandomTest
Diffstat (limited to 'jstests/core/geo_near_random1.js')
-rw-r--r--jstests/core/geo_near_random1.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/jstests/core/geo_near_random1.js b/jstests/core/geo_near_random1.js
index 50539f3ea5d..5c75b458957 100644
--- a/jstests/core/geo_near_random1.js
+++ b/jstests/core/geo_near_random1.js
@@ -1,12 +1,37 @@
-// this tests all points using $near
+// this tests all points
load("jstests/libs/geo_near_random.js");
var test = new GeoNearRandomTest("geo_near_random1");
test.insertPts(50);
+// test.testPt() runs geoNear commands at the given coordinates with
+// limits from 1 to nPts(# of inserted points). At the nth run, it
+// compares the first (n - 1) results with the result of the (n - 1)th
+// run to make sure they are identical. It also makes sure that the
+// distances are in increasing order. The test runs in O(N^2).
+
+// Test $near with a 2dindex
test.testPt([0,0]);
test.testPt(test.mkPt());
test.testPt(test.mkPt());
test.testPt(test.mkPt());
test.testPt(test.mkPt());
+
+opts = {sphere: 1};
+
+// Test $nearSphere with a 2d index
+test.testPt([0,0], opts);
+test.testPt(test.mkPt(), opts);
+test.testPt(test.mkPt(), opts);
+test.testPt(test.mkPt(), opts);
+test.testPt(test.mkPt(), opts);
+
+// Test $nearSphere with a 2dsphere index
+assert.commandWorked(db.geo_near_random1.dropIndex({loc: '2d'}));
+assert.commandWorked(db.geo_near_random1.ensureIndex({loc: '2dsphere'}));
+test.testPt([0,0], opts);
+test.testPt(test.mkPt(), opts);
+test.testPt(test.mkPt(), opts);
+test.testPt(test.mkPt(), opts);
+test.testPt(test.mkPt(), opts); \ No newline at end of file