summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/validate_checkBSONConformance.js
blob: cfe4fec0246a18bd9c96d677883304d8ba9f76fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Tests the usage of 'checkBSONConformance' option of the validate command.
 *
 * @tags: [requires_fcv_62]
 */

(function() {
"use strict";

const collName = "validate_checkBSONConformance";
const coll = db.getCollection(collName);
coll.drop();
assert.commandWorked(coll.insert({a: 1}));

assert.commandFailedWithCode(
    db.runCommand({validate: collName, checkBSONConformance: true, metadata: true}),
    ErrorCodes.InvalidOptions);

assert.commandFailedWithCode(
    db.runCommand({validate: collName, checkBSONConformance: true, repair: true}),
    ErrorCodes.InvalidOptions);

assert.commandWorked(
    db.runCommand({validate: collName, checkBSONConformance: true, background: true}));

assert.commandFailedWithCode(
    db.runCommand({validate: collName, checkBSONConformance: false, full: true}),
    ErrorCodes.InvalidOptions);

assert.commandWorked(db.runCommand({validate: collName, checkBSONConformance: true, full: true}));

assert.commandFailedWithCode(
    db.runCommand({validate: collName, checkBSONConformance: false, enforceFastCount: true}),
    ErrorCodes.InvalidOptions);

assert.commandWorked(
    db.runCommand({validate: collName, checkBSONConformance: true, enforceFastCount: true}));
})();