summaryrefslogtreecommitdiff
path: root/jstests/core/api/api_version_create.js
blob: f42dfd2c1b59db44936c975bc7e277af1d29ffd2 (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
39
/**
 * Tests the create command with API versioning enabled.
 *
 * @tags: [
 *   uses_api_parameters,
 * ]
 */
(function() {
"use strict";

const testDB = db.getSiblingDB("createAPIVersion");
testDB.dropDatabase();

// Test the command with 'apiStrict'.
assert.commandWorked(testDB.runCommand({create: "basicCreate", apiVersion: "1", apiStrict: true}));

// Test the command with 'apiStrict'.
assert.commandWorked(testDB.runCommand(
    {create: "basicCreateCappedFalse", capped: false, apiVersion: "1", apiStrict: true}));

// Test that creating a capped collection fails with apiStrict=true.
assert.commandFailedWithCode(testDB.runCommand({
    create: "withCappedTrue",
    capped: true,
    size: 1000,
    apiVersion: "1",
    apiStrict: true,
}),
                             ErrorCodes.APIStrictError);

// Test that creating a capped collection fails without the size parameter.
assert.commandFailedWithCode(testDB.runCommand({
    create: "withCappedTrueNoSize",
    capped: true,
    apiVersion: "1",
    apiStrict: true,
}),
                             ErrorCodes.InvalidOptions);
})();