summaryrefslogtreecommitdiff
path: root/src/mongo/shell/assert.js
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2017-02-28 11:01:46 -0500
committerMisha Tyulenev <misha@mongodb.com>2017-02-28 17:10:02 -0500
commit6fe8c420da0c1071bfb8abfd7e936059d4977472 (patch)
tree1467f8c7a80c4626200241e076f43fcbdefdf8d5 /src/mongo/shell/assert.js
parentc203a3be8076c4939011d03e958bc010422ac86d (diff)
downloadmongo-6fe8c420da0c1071bfb8abfd7e936059d4977472.tar.gz
SERVER-27773 add operationTime field to the command response
Diffstat (limited to 'src/mongo/shell/assert.js')
-rw-r--r--src/mongo/shell/assert.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mongo/shell/assert.js b/src/mongo/shell/assert.js
index 2ce8e1e3dce..946d7c82112 100644
--- a/src/mongo/shell/assert.js
+++ b/src/mongo/shell/assert.js
@@ -131,6 +131,23 @@ assert.neq = function(a, b, msg) {
doassert("[" + a + "] != [" + b + "] are equal : " + msg);
};
+assert.hasFields = function(o, arr, msg) {
+ var count = 0;
+ if (!Array.isArray(arr)) {
+ throw new Error("The second argument to assert.hasFields must be an array.");
+ }
+
+ for (var field in result) {
+ if (arr.includes(field)) {
+ count += 1;
+ }
+ }
+
+ if (count != arr.length) {
+ doassert("None of values from " + tojson(arr) + " was in " + tojson(o) + " : " + msg);
+ }
+};
+
assert.contains = function(o, arr, msg) {
var wasIn = false;
if (!Array.isArray(arr)) {