summaryrefslogtreecommitdiff
path: root/jstests/libs/mql_model_mongod_test_runner.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/libs/mql_model_mongod_test_runner.js')
-rw-r--r--jstests/libs/mql_model_mongod_test_runner.js80
1 files changed, 40 insertions, 40 deletions
diff --git a/jstests/libs/mql_model_mongod_test_runner.js b/jstests/libs/mql_model_mongod_test_runner.js
index f19e2ce1f12..4485c81cdc1 100644
--- a/jstests/libs/mql_model_mongod_test_runner.js
+++ b/jstests/libs/mql_model_mongod_test_runner.js
@@ -2,56 +2,56 @@
* Test runner responsible for parsing and executing a MQL MongoD model test json file.
*/
(function() {
- "use strict";
+"use strict";
- const jsonFilename = jsTestOptions().mqlTestFile;
- const mqlRootPath = jsTestOptions().mqlRootPath;
+const jsonFilename = jsTestOptions().mqlTestFile;
+const mqlRootPath = jsTestOptions().mqlRootPath;
- if (jsonFilename === undefined) {
- throw new Error('Undefined JSON file name: MQL Model tests must be run through resmoke.py');
- }
+if (jsonFilename === undefined) {
+ throw new Error('Undefined JSON file name: MQL Model tests must be run through resmoke.py');
+}
- // Populate collections with data fetched from the dataFile.
- function populateCollections(dataFile) {
- const data = JSON.parse(cat(mqlRootPath + dataFile));
+// Populate collections with data fetched from the dataFile.
+function populateCollections(dataFile) {
+ const data = JSON.parse(cat(mqlRootPath + dataFile));
- data.forEach(function(singleColl) {
- assert(singleColl.hasOwnProperty("namespace"), "MQL data model requires a 'namespace'");
- assert(singleColl.hasOwnProperty("data"), "MQL data model requires a 'data'");
+ data.forEach(function(singleColl) {
+ assert(singleColl.hasOwnProperty("namespace"), "MQL data model requires a 'namespace'");
+ assert(singleColl.hasOwnProperty("data"), "MQL data model requires a 'data'");
- const coll = db.getCollection(singleColl["namespace"]);
- coll.drop();
+ const coll = db.getCollection(singleColl["namespace"]);
+ coll.drop();
- singleColl["data"].forEach(function(doc) {
- assert.commandWorked(coll.insert(doc));
- });
+ singleColl["data"].forEach(function(doc) {
+ assert.commandWorked(coll.insert(doc));
});
- }
+ });
+}
- // Run a single find test.
- function runFindTest(testFile, dataFile, expected) {
- populateCollections(dataFile);
+// Run a single find test.
+function runFindTest(testFile, dataFile, expected) {
+ populateCollections(dataFile);
- const test = JSON.parse(cat(mqlRootPath + testFile));
+ const test = JSON.parse(cat(mqlRootPath + testFile));
- const results = db.getCollection(test["find"]).find(test["filter"], {_id: 0}).toArray();
+ const results = db.getCollection(test["find"]).find(test["filter"], {_id: 0}).toArray();
- assert.eq(results, expected);
- }
+ assert.eq(results, expected);
+}
- // Read a list of tests from the jsonFilename and execute them.
- const testList = JSON.parse(cat(jsonFilename));
- testList.forEach(function(singleTest) {
- if (singleTest.hasOwnProperty("match")) {
- // Skip the match test type as it is not directly supported by mongod.
- } else if (singleTest.hasOwnProperty("find")) {
- // Run the find test type.
- assert(singleTest.hasOwnProperty("data"), "MQL model test requires a 'data'");
- assert(singleTest.hasOwnProperty("expected"), "MQL model test requires a 'expected'");
-
- runFindTest(singleTest["find"], singleTest["data"], singleTest["expected"]);
- } else {
- throw new Error("Unknown test type: " + tojson(singleTest));
- }
- });
+// Read a list of tests from the jsonFilename and execute them.
+const testList = JSON.parse(cat(jsonFilename));
+testList.forEach(function(singleTest) {
+ if (singleTest.hasOwnProperty("match")) {
+ // Skip the match test type as it is not directly supported by mongod.
+ } else if (singleTest.hasOwnProperty("find")) {
+ // Run the find test type.
+ assert(singleTest.hasOwnProperty("data"), "MQL model test requires a 'data'");
+ assert(singleTest.hasOwnProperty("expected"), "MQL model test requires a 'expected'");
+
+ runFindTest(singleTest["find"], singleTest["data"], singleTest["expected"]);
+ } else {
+ throw new Error("Unknown test type: " + tojson(singleTest));
+ }
+});
}());