diff options
author | Ian Boros <ian.boros@10gen.com> | 2018-08-22 12:49:05 -0400 |
---|---|---|
committer | Ian Boros <ian.boros@10gen.com> | 2018-08-22 18:33:32 -0400 |
commit | 2bed54b084995f2c2dd048b6a70b6fd678e1ac30 (patch) | |
tree | d74967637c51d171406ba4be912abdc3eca419b6 /jstests | |
parent | 6dd6e4d307c54912f6aaa502a581af9cb9dbf055 (diff) | |
download | mongo-2bed54b084995f2c2dd048b6a70b6fd678e1ac30.tar.gz |
SERVER-36774 Allow shell assertion functions to take an object for the 'msg'
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/shell_assertions.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/jstests/noPassthrough/shell_assertions.js b/jstests/noPassthrough/shell_assertions.js index 8915d087a3e..88fdcaa79ab 100644 --- a/jstests/noPassthrough/shell_assertions.js +++ b/jstests/noPassthrough/shell_assertions.js @@ -133,6 +133,25 @@ assert.eq(true, called, 'called should not have been udpated'); }); + tests.push(function assertShouldAcceptObjectAsMsg() { + const objMsg = {someMessage: 1}; + const err = assert.throws(() => { + assert(false, objMsg); + }); + + assert.neq(-1, + err.message.indexOf(tojson(objMsg)), + 'Error message should have included ' + tojson(objMsg)); + }); + + tests.push(function assertShouldNotAcceptNonObjStringFunctionAsMsg() { + const err = assert.throws(() => { + assert(true, 1234); + }); + + assert.neq(-1, err.message.indexOf("msg parameter must be a ")); + }); + /* assert.automsg tests */ tests.push(function automsgShouldPassToAssert() { |