jstests/aggregation/extras/utils.js
/**
 * Assert that an aggregation fails with a specific code and the error message contains the given
 * string. Note that 'code' can be an array of possible codes.
 */
Assert that an aggregation fails with a specific code and the error message contains the given
string. Note that 'code' can be an array of possible codes.
Assert that an aggregation fails with a specific code and the error message contains the given string . Note that ' code ' can be an array of possible codes .
function assertErrCodeAndErrMsgContains(coll, pipe, code, expectedMessage) {
    const response = assert.commandFailedWithCode(
        coll.getDB().runCommand({aggregate: coll.getName(), pipeline: pipe, cursor: {}}), code);
    assert.neq(
        -1,
        response.errmsg.indexOf(expectedMessage),
        "Error message did not contain '" + expectedMessage + "', found:\n" + tojson(response));
}
function assertErrCodeAndErrMsgContains ( coll , pipe , code , expectedMessage ) { const response = assert . commandFailedWithCode ( coll . getDB ( ) . runCommand ( { aggregate : coll . getName ( ) , pipeline : pipe , cursor : { } } ) , code ) ; assert . neq ( - 1 , response . errmsg . indexOf ( expectedMessage ) , "Error message did not contain '" + expectedMessage + "', found:\n" + tojson ( response ) ) ; }
Assert that an aggregation fails with a specific code and the error message contains the given
 string.
Assert that an aggregation fails with a specific code and the error message contains the given string .