Files
mongo/jstests/with_mongot/e2e_infrastructure_tests/createSearchIndex_shell_command.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

37 lines
1.3 KiB
JavaScript

// 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);