Skip to content

Commit 7029428

Browse files
chore: adapt connect tool to use describeWithMongoDB
1 parent 4ae0952 commit 7029428

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

tests/integration/tools/mongodb/connect/connect.test.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { defaultTestSuiteConfig, describeWithMongoDB } from "../mongodbHelpers.js";
22
import {
3-
defaultDriverOptions,
43
getResponseContent,
54
getResponseElements,
65
validateThrowsForInvalidArguments,
76
validateToolMetadata,
87
} from "../../../helpers.js";
9-
import { defaultTestConfig, setupIntegrationTest } from "../../../helpers.js";
8+
import { defaultTestConfig } from "../../../helpers.js";
109
import { beforeEach, describe, expect, it } from "vitest";
1110

1211
describeWithMongoDB(
@@ -141,28 +140,30 @@ describeWithMongoDB("Connect tool", (integration) => {
141140
});
142141
});
143142

144-
describe("Connect tool when disabled", () => {
145-
const integration = setupIntegrationTest(
146-
() => ({
143+
describeWithMongoDB(
144+
"Connect tool when disabled",
145+
(integration) => {
146+
it("is not suggested when querying MongoDB disconnected", async () => {
147+
const response = await integration.mcpClient().callTool({
148+
name: "find",
149+
arguments: { database: "some-db", collection: "some-collection" },
150+
});
151+
152+
const elements = getResponseElements(response);
153+
expect(elements).toHaveLength(2);
154+
expect(elements[0]?.text).toContain(
155+
"You need to connect to a MongoDB instance before you can access its data."
156+
);
157+
expect(elements[1]?.text).toContain(
158+
"There are no tools available to connect. Please update the configuration to include a connection string and restart the server."
159+
);
160+
});
161+
},
162+
{
163+
...defaultTestSuiteConfig,
164+
getUserConfig: () => ({
147165
...defaultTestConfig,
148166
disabledTools: ["connect"],
149167
}),
150-
() => defaultDriverOptions
151-
);
152-
153-
it("is not suggested when querying MongoDB disconnected", async () => {
154-
const response = await integration.mcpClient().callTool({
155-
name: "find",
156-
arguments: { database: "some-db", collection: "some-collection" },
157-
});
158-
159-
const elements = getResponseElements(response);
160-
expect(elements).toHaveLength(2);
161-
expect(elements[0]?.text).toContain(
162-
"You need to connect to a MongoDB instance before you can access its data."
163-
);
164-
expect(elements[1]?.text).toContain(
165-
"There are no tools available to connect. Please update the configuration to include a connection string and restart the server."
166-
);
167-
});
168-
});
168+
}
169+
);

0 commit comments

Comments
 (0)