diff options
author | Kyle Suarez <kyle.suarez@mongodb.com> | 2017-11-22 10:43:58 -0500 |
---|---|---|
committer | Kyle Suarez <kyle.suarez@mongodb.com> | 2017-11-22 11:32:23 -0500 |
commit | 969ddd3d921cd8e6c5ab3068fdb77cb2dc271ed5 (patch) | |
tree | b92641c79b96fadf997711d6ed7d49947d5cc61d /jstests/core/find4.js | |
parent | 2b9095818a4b6fc0a797ff1dd25fdfe0792b99c1 (diff) | |
download | mongo-969ddd3d921cd8e6c5ab3068fdb77cb2dc271ed5.tar.gz |
SERVER-30384 tests should specify a sort when expecting an ordering for a query
This refactors several tests in core to not rely on an implicit sort
order, which allows them to be unblacklisted from the causally
consistent jscore passthroughs.
Diffstat (limited to 'jstests/core/find4.js')
-rw-r--r-- | jstests/core/find4.js | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/jstests/core/find4.js b/jstests/core/find4.js index 204e7c511e2..ad482916a19 100644 --- a/jstests/core/find4.js +++ b/jstests/core/find4.js @@ -1,36 +1,42 @@ +(function() { + "use strict"; -t = db.find4; -t.drop(); + const coll = db.find4; + coll.drop(); -t.save({a: 1123, b: 54332}); + assert.writeOK(coll.insert({a: 1123, b: 54332})); -o = t.find({}, {})[0]; -assert.eq(1123, o.a, "A"); -assert.eq(54332, o.b, "B"); -assert(o._id.str, "C"); + let o = coll.findOne(); + assert.eq(1123, o.a, "A"); + assert.eq(54332, o.b, "B"); + assert(o._id.str, "C"); -o = t.find({}, {a: 1})[0]; -assert.eq(1123, o.a, "D"); -assert(o._id.str, "E"); -assert(!o.b, "F"); + o = coll.findOne({}, {a: 1}); + assert.eq(1123, o.a, "D"); + assert(o._id.str, "E"); + assert(!o.b, "F"); -o = t.find({}, {b: 1})[0]; -assert.eq(54332, o.b, "G"); -assert(o._id.str, "H"); -assert(!o.a, "I"); + o = coll.findOne({}, {b: 1}); + assert.eq(54332, o.b, "G"); + assert(o._id.str, "H"); + assert(!o.a, "I"); -t.drop(); -t.save({a: 1, b: 1}); -t.save({a: 2, b: 2}); -assert.eq("1-1,2-2", - t.find() - .map(function(z) { - return z.a + "-" + z.b; - }) - .toString()); -assert.eq("1-undefined,2-undefined", - t.find({}, {a: 1}) - .map(function(z) { - return z.a + "-" + z.b; - }) - .toString()); + assert(coll.drop()); + + assert.writeOK(coll.insert({a: 1, b: 1})); + assert.writeOK(coll.insert({a: 2, b: 2})); + assert.eq("1-1,2-2", + coll.find() + .sort({a: 1}) + .map(function(z) { + return z.a + "-" + z.b; + }) + .toString()); + assert.eq("1-undefined,2-undefined", + coll.find({}, {a: 1}) + .sort({a: 1}) + .map(function(z) { + return z.a + "-" + z.b; + }) + .toString()); +}()); |