summaryrefslogtreecommitdiff
path: root/jstests/libs
diff options
context:
space:
mode:
authorNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-09-15 16:11:45 -0400
committerNick Zolnierz <nicholas.zolnierz@mongodb.com>2017-09-26 16:46:45 -0400
commitb1e0108555a28fc3f487be642e0d3ac34ddeb794 (patch)
treee4b9be14cc0b9bcd9169f740a25e774897d7cffa /jstests/libs
parent78f2325fbf771242457315819df2e5cb341eaeee (diff)
downloadmongo-b1e0108555a28fc3f487be642e0d3ac34ddeb794.tar.gz
SERVER-30987: Enable and test $jsonSchema in the aggregation $match stage
Diffstat (limited to 'jstests/libs')
-rw-r--r--jstests/libs/assert_schema_match.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/jstests/libs/assert_schema_match.js b/jstests/libs/assert_schema_match.js
index fe901829027..9a055c389af 100644
--- a/jstests/libs/assert_schema_match.js
+++ b/jstests/libs/assert_schema_match.js
@@ -8,7 +8,13 @@
function assertSchemaMatch(coll, schema, doc, valid) {
coll.drop();
assert.writeOK(coll.insert(doc));
- const count = coll.find({$jsonSchema: schema}).itcount();
- const errmsg = valid ? " should have matched the schema " : " unexpectedly matched the schema ";
- assert.eq(count, valid ? 1 : 0, "Document " + tojson(doc) + errmsg + tojson(schema));
+ let count = coll.find({$jsonSchema: schema}).itcount();
+ const errmsg = "Document " + tojson(doc) +
+ (valid ? " should have matched the schema " : " unexpectedly matched the schema ") +
+ tojson(schema);
+ assert.eq(count, valid ? 1 : 0, errmsg);
+
+ // Repeat the same query in an aggregation $match stage.
+ count = coll.aggregate([{$match: {$jsonSchema: schema}}]).itcount();
+ assert.eq(count, valid ? 1 : 0, errmsg + " in a $match stage");
}