Details
Description
assert.commandWorkedOrFailedWithCode = function commandWorkedOrFailedWithCode(res, errorCodeSet, msg) { |
if (!res.ok) { |
return assert.commandFailedWithCode(res, errorCodeSet, msg); |
} else { |
return assert.commandWorked(res, msg); |
}
|
};
|
But not all operations, such as insert, have the 'ok' field in the response. For those operations the commandFailedWithCode branch is always taken.
Possible fix:
assert.commandWorkedOrFailedWithCode = function commandWorkedOrFailedWithCode(res, errorCodeSet, msg) { |
try { return assert.commandWorked(res, msg); } |
catch (e) { return assert.commandFailedWithCode(res, errorCodeSet, msg); } |
};
|