summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/doc_validation.js23
1 files changed, 9 insertions, 14 deletions
diff --git a/jstests/core/doc_validation.js b/jstests/core/doc_validation.js
index b45531af62d..1b74032c7c3 100644
--- a/jstests/core/doc_validation.js
+++ b/jstests/core/doc_validation.js
@@ -11,26 +11,21 @@
(function() {
"use strict";
-const collName = "doc_validation";
-const coll = db[collName];
+function assertFailsValidation(res) {
+ if (res instanceof WriteResult) {
+ assert.writeErrorWithCode(res, ErrorCodes.DocumentValidationFailure, tojson(res));
+ } else {
+ assert.commandFailedWithCode(res, ErrorCodes.DocumentValidationFailure, tojson(res));
+ }
+}
const array = [];
for (let i = 0; i < 2048; i++) {
array.push({arbitrary: i});
}
-function assertFailsValidation(res) {
- // Assert that validation fails with a 'DocumentValidationFailure' error.
- assert.commandFailedWithCode(res, ErrorCodes.DocumentValidationFailure, tojson(res));
- // Verify that the 'errInfo' field is propagated as part of the document validation failure
- // for WriteErrors.
- // We don't currently support detailed error info for 'OP_INSERT' and 'OP_UPDATE'.
- if (coll.getMongo().writeMode() === "commands") {
- const error = res instanceof WriteResult ? res.getWriteError() : res;
- assert(error.hasOwnProperty("errInfo"), tojson(error));
- assert.eq(typeof error["errInfo"], "object", tojson(error));
- }
-}
+const collName = "doc_validation";
+const coll = db[collName];
/**
* Runs a series of document validation tests using the validator 'validator', which should