diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2015-10-30 20:32:16 +1100 |
---|---|---|
committer | Kevin Pulo <kevin.pulo@mongodb.com> | 2015-10-30 20:35:28 +1100 |
commit | 0c8b0d57c7072788e5f7f20af36214f0f9060099 (patch) | |
tree | aeabaeead9a17e925c0d9e56b85339f54e6aebe2 /jstests/core/distinct4.js | |
parent | 1ba041ab5d54d361fd04c0957493354caa99097b (diff) | |
download | mongo-0c8b0d57c7072788e5f7f20af36214f0f9060099.tar.gz |
SERVER-12746: Fix assert() calls with constant-value args
These calls were mostly mistakes that should have been assert.eq().
assert() will now trip if passed a non-string msg, or too many params.
Diffstat (limited to 'jstests/core/distinct4.js')
-rw-r--r-- | jstests/core/distinct4.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/jstests/core/distinct4.js b/jstests/core/distinct4.js index 5e4a1fd85a2..1fa2763bf40 100644 --- a/jstests/core/distinct4.js +++ b/jstests/core/distinct4.js @@ -15,7 +15,7 @@ //first argument should be a string or error // from shell helper - assert.throws( t.distinct, [{a:1}] ); + assert.throws( function () { t.distinct({a:1}); } ); // from command interface assert.commandFailedWithCode(t.runCommand("distinct", {"key": {a: 1}}), @@ -25,7 +25,7 @@ //second argument should be a document or error // from shell helper - assert.throws( t.distinct, ['a', '1'] ); + assert.throws( function () { t.distinct('a', '1'); } ); // from command interface assert.commandFailedWithCode(t.runCommand("distinct", {"key": "a", "query": "a"}), @@ -34,8 +34,17 @@ // empty query clause should not cause error - assert( t.runCommand( "distinct", { "key" : "a" } ) ); - assert( t.distinct, ['a'] ); + // from shell helper + var a = assert.doesNotThrow( function () { return t.distinct('a'); } ); + // [ null, 1, 2, 3 ] + assert.eq(4, a.length, tojson(a)); + assert.contains(null, a); + assert.contains(1, a); + assert.contains(2, a); + assert.contains(3, a); + + // from command interface + assert.commandWorked( t.runCommand( "distinct", { "key" : "a" } ) ); })(); |