From 5595b945603b0712c537787e31e6da661c424fee Mon Sep 17 00:00:00 2001 From: Randolph Tan Date: Tue, 14 Jan 2014 14:09:42 -0500 Subject: SERVER-12127 migrate js tests to jscore suite when not related to writes Moved test jstest/[a-i].js -> jstests/core/ and made changes to comply with write command api --- jstests/core/geob.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 jstests/core/geob.js (limited to 'jstests/core/geob.js') diff --git a/jstests/core/geob.js b/jstests/core/geob.js new file mode 100644 index 00000000000..0dcc2658ba2 --- /dev/null +++ b/jstests/core/geob.js @@ -0,0 +1,35 @@ +var t = db.geob; +t.drop(); + +var a = {p: [0, 0]}; +var b = {p: [1, 0]}; +var c = {p: [3, 4]}; +var d = {p: [0, 6]}; + +t.save(a); +t.save(b); +t.save(c); +t.save(d); +t.ensureIndex({p: "2d"}); + +var res = t.runCommand("geoNear", {near: [0,0]}); +assert.close(3, res.stats.avgDistance, "A"); + +assert.close(0, res.results[0].dis, "B1"); +assert.eq(a._id, res.results[0].obj._id, "B2"); + +assert.close(1, res.results[1].dis, "C1"); +assert.eq(b._id, res.results[1].obj._id, "C2"); + +assert.close(5, res.results[2].dis, "D1"); +assert.eq(c._id, res.results[2].obj._id, "D2"); + +assert.close(6, res.results[3].dis, "E1"); +assert.eq(d._id, res.results[3].obj._id, "E2"); + +res = t.runCommand("geoNear", {near: [0,0], distanceMultiplier: 2}); +assert.close(6, res.stats.avgDistance, "F"); +assert.close(0, res.results[0].dis, "G"); +assert.close(2, res.results[1].dis, "H"); +assert.close(10, res.results[2].dis, "I"); +assert.close(12, res.results[3].dis, "J"); -- cgit v1.2.1