summaryrefslogtreecommitdiff
path: root/jstests/aggregation/extras/utils.js
diff options
context:
space:
mode:
authorGeorge Wangensteen <george.wangensteen@10gen.com>2019-07-08 13:19:22 -0400
committerGeorge Wangensteen <george.wangensteen@10gen.com>2019-07-24 17:44:23 -0400
commitf4399fceab41c4dfaad6b846b94e1366f67d93cd (patch)
tree11f0fd253c9fd9cc1670725bb037e160efc47017 /jstests/aggregation/extras/utils.js
parente09a81707daf75e8965cc10d909282db158bc809 (diff)
downloadmongo-f4399fceab41c4dfaad6b846b94e1366f67d93cd.tar.gz
SERVER-42017 make stage names in error messages match name used
Diffstat (limited to 'jstests/aggregation/extras/utils.js')
-rw-r--r--jstests/aggregation/extras/utils.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/jstests/aggregation/extras/utils.js b/jstests/aggregation/extras/utils.js
index 3a8bbf5d071..57f61956792 100644
--- a/jstests/aggregation/extras/utils.js
+++ b/jstests/aggregation/extras/utils.js
@@ -269,7 +269,7 @@ function assertErrorCode(coll, pipe, code, errmsg, options = {}) {
* Assert that an aggregation fails with a specific code and the error message contains the given
* string.
*/
-function assertErrMsgContains(coll, pipe, code, expectedMessage) {
+function assertErrCodeAndErrMsgContains(coll, pipe, code, expectedMessage) {
const response = assert.commandFailedWithCode(
coll.getDB().runCommand({aggregate: coll.getName(), pipeline: pipe, cursor: {}}), code);
assert.neq(
@@ -279,6 +279,31 @@ function assertErrMsgContains(coll, pipe, code, expectedMessage) {
}
/**
+ * Assert that an aggregation fails with any code and the error message contains the given
+ * string.
+ */
+function assertErrMsgContains(coll, pipe, expectedMessage) {
+ const response = assert.commandFailed(
+ coll.getDB().runCommand({aggregate: coll.getName(), pipeline: pipe, cursor: {}}));
+ assert.neq(
+ -1,
+ response.errmsg.indexOf(expectedMessage),
+ "Error message did not contain '" + expectedMessage + "', found:\n" + tojson(response));
+}
+
+/**
+ * Assert that an aggregation fails with any code and the error message does not contain the given
+ * string.
+ */
+function assertErrMsgDoesNotContain(coll, pipe, expectedMessage) {
+ const response = assert.commandFailed(
+ coll.getDB().runCommand({aggregate: coll.getName(), pipeline: pipe, cursor: {}}));
+ assert.eq(-1,
+ response.errmsg.indexOf(expectedMessage),
+ "Error message contained '" + expectedMessage + "'");
+}
+
+/**
* Asserts that two arrays are equal - that is, if their sizes are equal and each element in
* the 'actual' array has a matching element in the 'expected' array, without honoring elements
* order.