Files
mongo/jstests/core/maxscan.js
Kyle Suarez 969ddd3d92 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.
2017-11-22 11:32:23 -05:00

22 lines
678 B
JavaScript

(function() {
"use strict";
const coll = db.maxscan;
coll.drop();
const N = 100;
for (let i = 0; i < N; i++) {
assert.writeOK(coll.insert({_id: i, x: i % 10}));
}
assert.eq(N, coll.find().itcount(), "A");
assert.eq(50, coll.find().maxScan(50).itcount(), "B");
assert.eq(10, coll.find({x: 2}).itcount(), "C");
assert.eq(5, coll.find({x: 2}).sort({_id: 1}).maxScan(50).itcount(), "D");
assert.commandWorked(coll.ensureIndex({x: 1}));
assert.eq(10, coll.find({x: 2}).sort({_id: 1}).hint({x: 1}).maxScan(N).itcount(), "E");
assert.eq(0, coll.find({x: 2}).sort({_id: 1}).hint({x: 1}).maxScan(1).itcount(), "E");
}());