diff options
Diffstat (limited to 'jstests/aggregation/extras/utils.js')
| -rw-r--r-- | jstests/aggregation/extras/utils.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/jstests/aggregation/extras/utils.js b/jstests/aggregation/extras/utils.js index bea13b293dc..972db80d43e 100644 --- a/jstests/aggregation/extras/utils.js +++ b/jstests/aggregation/extras/utils.js @@ -241,12 +241,31 @@ function assertErrorCode(coll, pipe, code, errmsg) { pipe = [pipe]; } + // Test non-cursor var res = coll.runCommand("aggregate", {pipeline: pipe}); - if (res.ok || res.code != code) printjson({pipeline: pipe, result: res}); /* assert failure with proper error code */ assert(!res.ok, errmsg || "failed in assertErrorCode"); assert.eq(res.code, code); + + // Test with cursors + var cmd = {pipeline: pipe}; + // cmd.cursor = {}; + cmd.cursor = {batchSize: 0}; + + var cursorRes = coll.runCommand("aggregate", cmd); + if (cursorRes.ok) { + var followupBatchSize = 0; // default + var cursor = new DBCommandCursor(coll.getMongo(), cursorRes, followupBatchSize); + + var error = assert.throws(function(){cursor.itcount()}, [], "expected error: " + code); + if (!error.search(code)) { + assert(false, "expected error: " + code + " got: " + error); + } + } + else { + assert.eq(cursorRes.code, code); + } } |
