From 4f757cb01ca1e4cd46324b14e0a045809b8b8190 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Wed, 23 Apr 2025 17:55:04 +0100 Subject: [PATCH 1/4] refactor: split test helpers --- tests/integration/helpers.ts | 58 ---------- .../mongodb/create/createCollection.test.ts | 5 +- .../tools/mongodb/create/createIndex.test.ts | 5 +- .../tools/mongodb/create/insertMany.test.ts | 5 +- .../tools/mongodb/delete/deleteMany.test.ts | 5 +- .../mongodb/delete/dropCollection.test.ts | 5 +- .../tools/mongodb/delete/dropDatabase.test.ts | 5 +- .../mongodb/metadata/collectionSchema.test.ts | 5 +- .../metadata/collectionStorageSize.test.ts | 5 +- .../tools/mongodb/metadata/connect.test.ts | 5 +- .../mongodb/metadata/listCollections.test.ts | 5 +- .../mongodb/metadata/listDatabases.test.ts | 5 +- .../tools/mongodb/mongodbHelpers.ts | 109 ++++++++++++++++++ .../tools/mongodb/read/count.test.ts | 5 +- 14 files changed, 145 insertions(+), 82 deletions(-) create mode 100644 tests/integration/tools/mongodb/mongodbHelpers.ts diff --git a/tests/integration/helpers.ts b/tests/integration/helpers.ts index 4e236b1a..9270b8eb 100644 --- a/tests/integration/helpers.ts +++ b/tests/integration/helpers.ts @@ -23,16 +23,9 @@ type ToolInfo = Awaited>["tools"][number]; export interface IntegrationTest { mcpClient: () => Client; mcpServer: () => Server; - mongoClient: () => MongoClient; - connectionString: () => string; - connectMcpClient: () => Promise; - randomDbName: () => string; } export function setupIntegrationTest(userConfig: UserConfig = config): IntegrationTest { - let mongoCluster: runner.MongoCluster | undefined; - let mongoClient: MongoClient | undefined; - let mcpClient: Client | undefined; let mcpServer: Server | undefined; @@ -76,10 +69,6 @@ export function setupIntegrationTest(userConfig: UserConfig = config): Integrati await mcpClient.connect(clientTransport); }); - beforeEach(async () => { - randomDbName = new ObjectId().toString(); - }); - afterAll(async () => { await mcpClient?.close(); mcpClient = undefined; @@ -88,54 +77,7 @@ export function setupIntegrationTest(userConfig: UserConfig = config): Integrati mcpServer = undefined; }); - afterEach(async () => { - await mcpServer?.session.close(); - config.connectionString = undefined; - await mongoClient?.close(); - mongoClient = undefined; - }); - - beforeAll(async function () { - // Downloading Windows executables in CI takes a long time because - // they include debug symbols... - const tmpDir = path.join(__dirname, "..", "tmp"); - await fs.mkdir(tmpDir, { recursive: true }); - - // On Windows, we may have a situation where mongod.exe is not fully released by the OS - // before we attempt to run it again, so we add a retry. - let dbsDir = path.join(tmpDir, "mongodb-runner", "dbs"); - for (let i = 0; i < 10; i++) { - try { - mongoCluster = await MongoCluster.start({ - tmpDir: dbsDir, - logDir: path.join(tmpDir, "mongodb-runner", "logs"), - topology: "standalone", - }); - - return; - } catch (err) { - if (i < 5) { - // Just wait a little bit and retry - console.error(`Failed to start cluster in ${dbsDir}, attempt ${i}: ${err}`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - } else { - // If we still fail after 5 seconds, try another db dir - console.error( - `Failed to start cluster in ${dbsDir}, attempt ${i}: ${err}. Retrying with a new db dir.` - ); - dbsDir = path.join(tmpDir, "mongodb-runner", `dbs${i - 5}`); - } - } - } - - throw new Error("Failed to start cluster after 10 attempts"); - }, 120_000); - - afterAll(async function () { - await mongoCluster?.close(); - mongoCluster = undefined; - }); const getMcpClient = () => { if (!mcpClient) { diff --git a/tests/integration/tools/mongodb/create/createCollection.test.ts b/tests/integration/tools/mongodb/create/createCollection.test.ts index a03c8ed3..b3cce49f 100644 --- a/tests/integration/tools/mongodb/create/createCollection.test.ts +++ b/tests/integration/tools/mongodb/create/createCollection.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -8,8 +10,7 @@ import { dbOperationInvalidArgTests, } from "../../../helpers.js"; -describe("createCollection tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("createCollection tool", (integration) => { validateToolMetadata( integration, diff --git a/tests/integration/tools/mongodb/create/createIndex.test.ts b/tests/integration/tools/mongodb/create/createIndex.test.ts index 1dcc1ecd..4ef43599 100644 --- a/tests/integration/tools/mongodb/create/createIndex.test.ts +++ b/tests/integration/tools/mongodb/create/createIndex.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -8,8 +10,7 @@ import { } from "../../../helpers.js"; import { IndexDirection } from "mongodb"; -describe("createIndex tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("createIndex tool", (integration) => { validateToolMetadata(integration, "create-index", "Create an index for a collection", [ ...dbOperationParameters, diff --git a/tests/integration/tools/mongodb/create/insertMany.test.ts b/tests/integration/tools/mongodb/create/insertMany.test.ts index f549fbbc..29166aee 100644 --- a/tests/integration/tools/mongodb/create/insertMany.test.ts +++ b/tests/integration/tools/mongodb/create/insertMany.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -7,8 +9,7 @@ import { validateThrowsForInvalidArguments, } from "../../../helpers.js"; -describe("insertMany tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("insertMany tool", (integration) => { validateToolMetadata(integration, "insert-many", "Insert an array of documents into a MongoDB collection", [ ...dbOperationParameters, diff --git a/tests/integration/tools/mongodb/delete/deleteMany.test.ts b/tests/integration/tools/mongodb/delete/deleteMany.test.ts index accbe218..7a7df74c 100644 --- a/tests/integration/tools/mongodb/delete/deleteMany.test.ts +++ b/tests/integration/tools/mongodb/delete/deleteMany.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -7,8 +9,7 @@ import { validateThrowsForInvalidArguments, } from "../../../helpers.js"; -describe("deleteMany tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("deleteMany tool", (integration) => { validateToolMetadata( integration, diff --git a/tests/integration/tools/mongodb/delete/dropCollection.test.ts b/tests/integration/tools/mongodb/delete/dropCollection.test.ts index 0044231d..6221581d 100644 --- a/tests/integration/tools/mongodb/delete/dropCollection.test.ts +++ b/tests/integration/tools/mongodb/delete/dropCollection.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -8,8 +10,7 @@ import { dbOperationInvalidArgTests, } from "../../../helpers.js"; -describe("dropCollection tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("dropCollection tool", (integration) => { validateToolMetadata( integration, diff --git a/tests/integration/tools/mongodb/delete/dropDatabase.test.ts b/tests/integration/tools/mongodb/delete/dropDatabase.test.ts index 6ed31afb..aaf0ee06 100644 --- a/tests/integration/tools/mongodb/delete/dropDatabase.test.ts +++ b/tests/integration/tools/mongodb/delete/dropDatabase.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -8,8 +10,7 @@ import { dbOperationInvalidArgTests, } from "../../../helpers.js"; -describe("dropDatabase tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("dropDatabase tool", (integration) => { validateToolMetadata( integration, diff --git a/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts b/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts index 339dd113..7368f1e2 100644 --- a/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts +++ b/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseElements, getResponseContent, @@ -12,8 +14,7 @@ import { Document } from "bson"; import { OptionalId } from "mongodb"; import { SimplifiedSchema } from "mongodb-schema"; -describe("collectionSchema tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("collectionSchema tool", (integration) => { validateToolMetadata( integration, diff --git a/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts b/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts index 4af84030..1ed912df 100644 --- a/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts +++ b/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, setupIntegrationTest, @@ -9,8 +11,7 @@ import { } from "../../../helpers.js"; import * as crypto from "crypto"; -describe("collectionStorageSize tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("collectionStorageSize tool", (integration) => { validateToolMetadata( integration, diff --git a/tests/integration/tools/mongodb/metadata/connect.test.ts b/tests/integration/tools/mongodb/metadata/connect.test.ts index 3f28a66d..bdfa3d6d 100644 --- a/tests/integration/tools/mongodb/metadata/connect.test.ts +++ b/tests/integration/tools/mongodb/metadata/connect.test.ts @@ -1,9 +1,10 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, setupIntegrationTest, validateToolMetadata } from "../../../helpers.js"; import { config } from "../../../../../src/config.js"; -describe("Connect tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("Connect tool", (integration) => { validateToolMetadata(integration, "connect", "Connect to a MongoDB instance", [ { diff --git a/tests/integration/tools/mongodb/metadata/listCollections.test.ts b/tests/integration/tools/mongodb/metadata/listCollections.test.ts index f6fb9bc0..096e4545 100644 --- a/tests/integration/tools/mongodb/metadata/listCollections.test.ts +++ b/tests/integration/tools/mongodb/metadata/listCollections.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseElements, getResponseContent, @@ -8,8 +10,7 @@ import { dbOperationInvalidArgTests, } from "../../../helpers.js"; -describe("listCollections tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("listCollections tool", (integration) => { validateToolMetadata(integration, "list-collections", "List all collections for a given database", [ { name: "database", description: "Database name", type: "string", required: true }, diff --git a/tests/integration/tools/mongodb/metadata/listDatabases.test.ts b/tests/integration/tools/mongodb/metadata/listDatabases.test.ts index 6d8ee7a3..75f039ea 100644 --- a/tests/integration/tools/mongodb/metadata/listDatabases.test.ts +++ b/tests/integration/tools/mongodb/metadata/listDatabases.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseElements, getParameters, @@ -6,8 +8,7 @@ import { } from "../../../helpers.js"; import { toIncludeSameMembers } from "jest-extended"; -describe("listDatabases tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("listDatabases tool", (integration) => { const defaultDatabases = ["admin", "config", "local"]; it("should have correct metadata", async () => { diff --git a/tests/integration/tools/mongodb/mongodbHelpers.ts b/tests/integration/tools/mongodb/mongodbHelpers.ts new file mode 100644 index 00000000..a196a7b6 --- /dev/null +++ b/tests/integration/tools/mongodb/mongodbHelpers.ts @@ -0,0 +1,109 @@ +import runner, { MongoCluster } from "mongodb-runner"; +import path from "path"; +import fs from "fs/promises"; +import { MongoClient, ObjectId } from "mongodb"; +import { IntegrationTest, setupIntegrationTest } from "../../helpers.js"; +import { UserConfig, config } from "../../../../src/config.js"; + +interface MongoDBIntegrationTest { + mongoClient: () => MongoClient; + connectionString: () => string; + connectMcpClient: () => Promise; + randomDbName: () => string; +} + +export function describeMongoDB(name: number | string | Function | jest.FunctionLike, fn: (integration: IntegrationTest & MongoDBIntegrationTest) => void): void { + describe("mongodb", () => { + const integration = setupIntegrationTest(); + const mdbIntegration = setupMongoDBIntegrationTest(integration); + describe(name, () => { + fn({...integration, ...mdbIntegration}); + }); + }); +} + +export function setupMongoDBIntegrationTest(integration: IntegrationTest, userConfig: UserConfig = config): MongoDBIntegrationTest { + let mongoCluster: runner.MongoCluster | undefined; + let mongoClient: MongoClient | undefined; + let randomDbName: string; + + beforeEach(async () => { + randomDbName = new ObjectId().toString(); + }); + + afterEach(async () => { + await integration.mcpServer().session.close(); + config.connectionString = undefined; + + await mongoClient?.close(); + mongoClient = undefined; + }); + + const tmpDir = path.join(__dirname, "..", "tmp"); + + beforeAll(async function () { + // Downloading Windows executables in CI takes a long time because + // they include debug symbols... + await fs.mkdir(tmpDir, { recursive: true }); + + // On Windows, we may have a situation where mongod.exe is not fully released by the OS + // before we attempt to run it again, so we add a retry. + let dbsDir = path.join(tmpDir, "mongodb-runner", "dbs"); + for (let i = 0; i < 10; i++) { + try { + mongoCluster = await MongoCluster.start({ + tmpDir: dbsDir, + logDir: path.join(tmpDir, "mongodb-runner", "logs"), + topology: "standalone", + }); + + return; + } catch (err) { + if (i < 5) { + // Just wait a little bit and retry + console.error(`Failed to start cluster in ${dbsDir}, attempt ${i}: ${err}`); + await new Promise((resolve) => setTimeout(resolve, 1000)); + } else { + // If we still fail after 5 seconds, try another db dir + console.error( + `Failed to start cluster in ${dbsDir}, attempt ${i}: ${err}. Retrying with a new db dir.` + ); + dbsDir = path.join(tmpDir, "mongodb-runner", `dbs${i - 5}`); + } + } + } + + throw new Error("Failed to start cluster after 10 attempts"); + }, 120_000); + + afterAll(async function () { + await mongoCluster?.close(); + mongoCluster = undefined; + await fs.rmdir(tmpDir, { recursive: true }); + }); + + const getConnectionString = () => { + if (!mongoCluster) { + throw new Error("beforeAll() hook not ran yet"); + } + + return mongoCluster.connectionString; + }; + + return { + mongoClient: () => { + if (!mongoClient) { + mongoClient = new MongoClient(getConnectionString()); + } + return mongoClient; + }, + connectionString: getConnectionString, + connectMcpClient: async () => { + await integration.mcpClient().callTool({ + name: "connect", + arguments: { options: [{ connectionString: getConnectionString() }] }, + }); + }, + randomDbName: () => randomDbName, + }; +} diff --git a/tests/integration/tools/mongodb/read/count.test.ts b/tests/integration/tools/mongodb/read/count.test.ts index 869c1ea2..bfde1432 100644 --- a/tests/integration/tools/mongodb/read/count.test.ts +++ b/tests/integration/tools/mongodb/read/count.test.ts @@ -1,3 +1,5 @@ +import { describeMongoDB } from "../mongodbHelpers.js"; + import { getResponseContent, dbOperationParameters, @@ -7,8 +9,7 @@ import { validateThrowsForInvalidArguments, } from "../../../helpers.js"; -describe("count tool", () => { - const integration = setupIntegrationTest(); +describeMongoDB("count tool", (integration) => { validateToolMetadata(integration, "count", "Gets the number of documents in a MongoDB collection", [ { From 773d10acf2a86f0c6b6bb142767572a217d386ed Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Wed, 23 Apr 2025 18:01:04 +0100 Subject: [PATCH 2/4] fix: test tmp folder --- tests/integration/tools/mongodb/mongodbHelpers.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integration/tools/mongodb/mongodbHelpers.ts b/tests/integration/tools/mongodb/mongodbHelpers.ts index a196a7b6..cc5eb309 100644 --- a/tests/integration/tools/mongodb/mongodbHelpers.ts +++ b/tests/integration/tools/mongodb/mongodbHelpers.ts @@ -39,11 +39,10 @@ export function setupMongoDBIntegrationTest(integration: IntegrationTest, userCo mongoClient = undefined; }); - const tmpDir = path.join(__dirname, "..", "tmp"); - beforeAll(async function () { // Downloading Windows executables in CI takes a long time because // they include debug symbols... + const tmpDir = path.join(__dirname, "..", "..", "..", "tmp"); await fs.mkdir(tmpDir, { recursive: true }); // On Windows, we may have a situation where mongod.exe is not fully released by the OS @@ -79,7 +78,6 @@ export function setupMongoDBIntegrationTest(integration: IntegrationTest, userCo afterAll(async function () { await mongoCluster?.close(); mongoCluster = undefined; - await fs.rmdir(tmpDir, { recursive: true }); }); const getConnectionString = () => { From bf9db9b6215663cca67aed134eb142fc0f9e6cde Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 24 Apr 2025 09:30:55 +0100 Subject: [PATCH 3/4] fix: styles --- tests/integration/helpers.ts | 2 -- .../tools/mongodb/create/createCollection.test.ts | 1 - .../tools/mongodb/create/createIndex.test.ts | 1 - .../tools/mongodb/create/insertMany.test.ts | 1 - .../tools/mongodb/delete/deleteMany.test.ts | 1 - .../tools/mongodb/delete/dropCollection.test.ts | 1 - .../tools/mongodb/delete/dropDatabase.test.ts | 1 - .../tools/mongodb/metadata/collectionSchema.test.ts | 1 - .../mongodb/metadata/collectionStorageSize.test.ts | 1 - .../tools/mongodb/metadata/connect.test.ts | 1 - .../tools/mongodb/metadata/listCollections.test.ts | 1 - tests/integration/tools/mongodb/mongodbHelpers.ts | 12 +++++++++--- tests/integration/tools/mongodb/read/count.test.ts | 1 - 13 files changed, 9 insertions(+), 16 deletions(-) diff --git a/tests/integration/helpers.ts b/tests/integration/helpers.ts index fe91954e..895970a6 100644 --- a/tests/integration/helpers.ts +++ b/tests/integration/helpers.ts @@ -82,8 +82,6 @@ export function setupIntegrationTest(userConfig: UserConfig = config): Integrati mcpServer = undefined; }); - - const getMcpClient = () => { if (!mcpClient) { throw new Error("beforeEach() hook not ran yet"); diff --git a/tests/integration/tools/mongodb/create/createCollection.test.ts b/tests/integration/tools/mongodb/create/createCollection.test.ts index b3cce49f..1735bad7 100644 --- a/tests/integration/tools/mongodb/create/createCollection.test.ts +++ b/tests/integration/tools/mongodb/create/createCollection.test.ts @@ -11,7 +11,6 @@ import { } from "../../../helpers.js"; describeMongoDB("createCollection tool", (integration) => { - validateToolMetadata( integration, "create-collection", diff --git a/tests/integration/tools/mongodb/create/createIndex.test.ts b/tests/integration/tools/mongodb/create/createIndex.test.ts index 4ef43599..c2c12417 100644 --- a/tests/integration/tools/mongodb/create/createIndex.test.ts +++ b/tests/integration/tools/mongodb/create/createIndex.test.ts @@ -11,7 +11,6 @@ import { import { IndexDirection } from "mongodb"; describeMongoDB("createIndex tool", (integration) => { - validateToolMetadata(integration, "create-index", "Create an index for a collection", [ ...dbOperationParameters, { diff --git a/tests/integration/tools/mongodb/create/insertMany.test.ts b/tests/integration/tools/mongodb/create/insertMany.test.ts index 29166aee..9668647f 100644 --- a/tests/integration/tools/mongodb/create/insertMany.test.ts +++ b/tests/integration/tools/mongodb/create/insertMany.test.ts @@ -10,7 +10,6 @@ import { } from "../../../helpers.js"; describeMongoDB("insertMany tool", (integration) => { - validateToolMetadata(integration, "insert-many", "Insert an array of documents into a MongoDB collection", [ ...dbOperationParameters, { diff --git a/tests/integration/tools/mongodb/delete/deleteMany.test.ts b/tests/integration/tools/mongodb/delete/deleteMany.test.ts index 7a7df74c..e5db88f1 100644 --- a/tests/integration/tools/mongodb/delete/deleteMany.test.ts +++ b/tests/integration/tools/mongodb/delete/deleteMany.test.ts @@ -10,7 +10,6 @@ import { } from "../../../helpers.js"; describeMongoDB("deleteMany tool", (integration) => { - validateToolMetadata( integration, "delete-many", diff --git a/tests/integration/tools/mongodb/delete/dropCollection.test.ts b/tests/integration/tools/mongodb/delete/dropCollection.test.ts index 6221581d..b2b61f65 100644 --- a/tests/integration/tools/mongodb/delete/dropCollection.test.ts +++ b/tests/integration/tools/mongodb/delete/dropCollection.test.ts @@ -11,7 +11,6 @@ import { } from "../../../helpers.js"; describeMongoDB("dropCollection tool", (integration) => { - validateToolMetadata( integration, "drop-collection", diff --git a/tests/integration/tools/mongodb/delete/dropDatabase.test.ts b/tests/integration/tools/mongodb/delete/dropDatabase.test.ts index aaf0ee06..0b06f532 100644 --- a/tests/integration/tools/mongodb/delete/dropDatabase.test.ts +++ b/tests/integration/tools/mongodb/delete/dropDatabase.test.ts @@ -11,7 +11,6 @@ import { } from "../../../helpers.js"; describeMongoDB("dropDatabase tool", (integration) => { - validateToolMetadata( integration, "drop-database", diff --git a/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts b/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts index 7368f1e2..7a14979b 100644 --- a/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts +++ b/tests/integration/tools/mongodb/metadata/collectionSchema.test.ts @@ -15,7 +15,6 @@ import { OptionalId } from "mongodb"; import { SimplifiedSchema } from "mongodb-schema"; describeMongoDB("collectionSchema tool", (integration) => { - validateToolMetadata( integration, "collection-schema", diff --git a/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts b/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts index 1ed912df..fb2259bd 100644 --- a/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts +++ b/tests/integration/tools/mongodb/metadata/collectionStorageSize.test.ts @@ -12,7 +12,6 @@ import { import * as crypto from "crypto"; describeMongoDB("collectionStorageSize tool", (integration) => { - validateToolMetadata( integration, "collection-storage-size", diff --git a/tests/integration/tools/mongodb/metadata/connect.test.ts b/tests/integration/tools/mongodb/metadata/connect.test.ts index bdfa3d6d..fc80a1be 100644 --- a/tests/integration/tools/mongodb/metadata/connect.test.ts +++ b/tests/integration/tools/mongodb/metadata/connect.test.ts @@ -5,7 +5,6 @@ import { getResponseContent, setupIntegrationTest, validateToolMetadata } from " import { config } from "../../../../../src/config.js"; describeMongoDB("Connect tool", (integration) => { - validateToolMetadata(integration, "connect", "Connect to a MongoDB instance", [ { name: "options", diff --git a/tests/integration/tools/mongodb/metadata/listCollections.test.ts b/tests/integration/tools/mongodb/metadata/listCollections.test.ts index 096e4545..b3e9a7d8 100644 --- a/tests/integration/tools/mongodb/metadata/listCollections.test.ts +++ b/tests/integration/tools/mongodb/metadata/listCollections.test.ts @@ -11,7 +11,6 @@ import { } from "../../../helpers.js"; describeMongoDB("listCollections tool", (integration) => { - validateToolMetadata(integration, "list-collections", "List all collections for a given database", [ { name: "database", description: "Database name", type: "string", required: true }, ]); diff --git a/tests/integration/tools/mongodb/mongodbHelpers.ts b/tests/integration/tools/mongodb/mongodbHelpers.ts index cc5eb309..4e5140f0 100644 --- a/tests/integration/tools/mongodb/mongodbHelpers.ts +++ b/tests/integration/tools/mongodb/mongodbHelpers.ts @@ -12,17 +12,23 @@ interface MongoDBIntegrationTest { randomDbName: () => string; } -export function describeMongoDB(name: number | string | Function | jest.FunctionLike, fn: (integration: IntegrationTest & MongoDBIntegrationTest) => void): void { +export function describeMongoDB( + name: number | string | Function | jest.FunctionLike, + fn: (integration: IntegrationTest & MongoDBIntegrationTest) => void +): void { describe("mongodb", () => { const integration = setupIntegrationTest(); const mdbIntegration = setupMongoDBIntegrationTest(integration); describe(name, () => { - fn({...integration, ...mdbIntegration}); + fn({ ...integration, ...mdbIntegration }); }); }); } -export function setupMongoDBIntegrationTest(integration: IntegrationTest, userConfig: UserConfig = config): MongoDBIntegrationTest { +export function setupMongoDBIntegrationTest( + integration: IntegrationTest, + userConfig: UserConfig = config +): MongoDBIntegrationTest { let mongoCluster: runner.MongoCluster | undefined; let mongoClient: MongoClient | undefined; let randomDbName: string; diff --git a/tests/integration/tools/mongodb/read/count.test.ts b/tests/integration/tools/mongodb/read/count.test.ts index bfde1432..cf00c750 100644 --- a/tests/integration/tools/mongodb/read/count.test.ts +++ b/tests/integration/tools/mongodb/read/count.test.ts @@ -10,7 +10,6 @@ import { } from "../../../helpers.js"; describeMongoDB("count tool", (integration) => { - validateToolMetadata(integration, "count", "Gets the number of documents in a MongoDB collection", [ { name: "query", From 82b3d4b8ae94d21d115e6ba66a8196196fbd12f5 Mon Sep 17 00:00:00 2001 From: Filipe C Menezes Date: Thu, 24 Apr 2025 09:57:20 +0100 Subject: [PATCH 4/4] fix: rename describes --- tests/integration/tools/atlas/atlasHelpers.ts | 2 +- tests/integration/tools/mongodb/mongodbHelpers.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/tools/atlas/atlasHelpers.ts b/tests/integration/tools/atlas/atlasHelpers.ts index f7d4802d..36b88c1e 100644 --- a/tests/integration/tools/atlas/atlasHelpers.ts +++ b/tests/integration/tools/atlas/atlasHelpers.ts @@ -9,7 +9,7 @@ export function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -export function describeAtlas(name: number | string | Function | jest.FunctionLike, fn: IntegrationTestFunction) { +export function describeWithAtlas(name: number | string | Function | jest.FunctionLike, fn: IntegrationTestFunction) { const testDefinition = () => { const integration = setupIntegrationTest(); describe(name, () => { diff --git a/tests/integration/tools/mongodb/mongodbHelpers.ts b/tests/integration/tools/mongodb/mongodbHelpers.ts index 4e5140f0..69814f57 100644 --- a/tests/integration/tools/mongodb/mongodbHelpers.ts +++ b/tests/integration/tools/mongodb/mongodbHelpers.ts @@ -12,7 +12,7 @@ interface MongoDBIntegrationTest { randomDbName: () => string; } -export function describeMongoDB( +export function describeWithMongoDB( name: number | string | Function | jest.FunctionLike, fn: (integration: IntegrationTest & MongoDBIntegrationTest) => void ): void {