Files
mongo/jstests/with_mongot/e2e_infrastructure_tests/createSearchIndex_shell_command.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.3 KiB
JavaScript
Raw Normal View History

// This test ensures correct error handling for the createSearchIndex shell command
import {createSearchIndex} from "jstests/libs/search.js";
const coll = db[jsTestName()];
coll.drop();
let error = assert.throws(() =>
createSearchIndex(
coll,
{name: "foo-block", definition: {"mappings": {"dynamic": true}}},
{blockUntilSearchIndexQueryable: "true"},
),
);
let expectedMessage = "Error: 'blockUntilSearchIndexQueryable' argument must be a boolean";
assert.eq(error, expectedMessage);
error = assert.throws(() =>
createSearchIndex(coll, {name: "foo-block", definition: {"mappings": {"dynamic": true}}}, {arg2: 1}),
);
expectedMessage =
"Error: createSearchIndex only accepts index definition object and blockUntilSearchIndexQueryable object";
assert.eq(error, expectedMessage);
error = assert.throws(() =>
createSearchIndex(
coll,
{name: "foo-block", definition: {"mappings": {"dynamic": true}}},
{arg2: 1},
{arg3: "three"},
),
);
expectedMessage = "Error: createSearchIndex accepts up to 3 arguments";
assert.eq(error, expectedMessage);
error = assert.throws(() => createSearchIndex(coll, {name: "foo-block"}));
expectedMessage = "Error: createSearchIndex must have a definition";
assert.eq(error, expectedMessage);