summaryrefslogtreecommitdiff
path: root/jstests/core/fts1.js
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2017-11-22 10:43:58 -0500
committerKyle Suarez <kyle.suarez@mongodb.com>2017-11-22 11:32:23 -0500
commit969ddd3d921cd8e6c5ab3068fdb77cb2dc271ed5 (patch)
treeb92641c79b96fadf997711d6ed7d49947d5cc61d /jstests/core/fts1.js
parent2b9095818a4b6fc0a797ff1dd25fdfe0792b99c1 (diff)
downloadmongo-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/fts1.js')
-rw-r--r--jstests/core/fts1.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/jstests/core/fts1.js b/jstests/core/fts1.js
index 5f507733b05..9b95fa8dc14 100644
--- a/jstests/core/fts1.js
+++ b/jstests/core/fts1.js
@@ -1,24 +1,27 @@
// Cannot implicitly shard accessed collections because of extra shard key index in sharded
// collection.
// @tags: [assumes_no_implicit_index_creation]
+(function() {
+ "use strict";
-load("jstests/libs/fts.js");
+ load("jstests/libs/fts.js");
-t = db.text1;
-t.drop();
+ const coll = db.text1;
+ coll.drop();
-t.ensureIndex({x: "text"});
+ assert.commandWorked(coll.createIndex({x: "text"}, {name: "x_text"}));
-assert.eq([], queryIDS(t, "az"), "A0");
+ assert.eq([], queryIDS(coll, "az"), "A0");
-t.save({_id: 1, x: "az b c"});
-t.save({_id: 2, x: "az b"});
-t.save({_id: 3, x: "b c"});
-t.save({_id: 4, x: "b c d"});
+ assert.writeOK(coll.insert({_id: 1, x: "az b c"}));
+ assert.writeOK(coll.insert({_id: 2, x: "az b"}));
+ assert.writeOK(coll.insert({_id: 3, x: "b c"}));
+ assert.writeOK(coll.insert({_id: 4, x: "b c d"}));
-assert.eq([1, 2, 3, 4], queryIDS(t, "c az"), "A1");
-assert.eq([4], queryIDS(t, "d"), "A2");
+ assert.eq([1, 2, 3, 4], queryIDS(coll, "c az").sort(), "A1");
+ assert.eq([4], queryIDS(coll, "d"), "A2");
-idx = t.getIndexes()[1];
-assert(idx.v >= 1, tojson(idx));
-assert(idx.textIndexVersion >= 1, tojson(idx));
+ const index = coll.getIndexes().find(index => index.name === "x_text");
+ assert.neq(index, undefined);
+ assert.gte(index.textIndexVersion, 1, tojson(index));
+}());