Skip to content

Commit 3eee38c

Browse files
committed
address comments: create default test config
1 parent a95af7b commit 3eee38c

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

tests/integration/helpers.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { UserConfig } from "../../src/config.js";
55
import { McpError } from "@modelcontextprotocol/sdk/types.js";
66
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
77
import { Session } from "../../src/session.js";
8+
import { config } from "../../src/config.js";
89

910
interface ParameterInfo {
1011
name: string;
@@ -19,16 +20,16 @@ export interface IntegrationTest {
1920
mcpClient: () => Client;
2021
mcpServer: () => Server;
2122
}
23+
export const defaultTestConfig: UserConfig = {
24+
...config,
25+
telemetry: "disabled",
26+
};
2227

2328
export function setupIntegrationTest(getUserConfig: () => UserConfig): IntegrationTest {
2429
let mcpClient: Client | undefined;
2530
let mcpServer: Server | undefined;
26-
let oldDoNotTrackValue: string | undefined;
2731

2832
beforeAll(async () => {
29-
// GET DO_NOT_TRACK value
30-
oldDoNotTrackValue = process.env.DO_NOT_TRACK;
31-
process.env.DO_NOT_TRACK = "1";
3233
const userConfig = getUserConfig();
3334
const clientTransport = new InMemoryTransport();
3435
const serverTransport = new InMemoryTransport();
@@ -79,13 +80,6 @@ export function setupIntegrationTest(getUserConfig: () => UserConfig): Integrati
7980

8081
await mcpServer?.close();
8182
mcpServer = undefined;
82-
83-
// Reset DO_NOT_TRACK value
84-
if (oldDoNotTrackValue !== undefined) {
85-
process.env.DO_NOT_TRACK = oldDoNotTrackValue;
86-
} else {
87-
delete process.env.DO_NOT_TRACK;
88-
}
8983
});
9084

9185
const getMcpClient = () => {

tests/integration/server.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { expectDefined, setupIntegrationTest } from "./helpers.js";
2-
import { config } from "../../src/config.js";
1+
import { defaultTestConfig, expectDefined, setupIntegrationTest } from "./helpers.js";
32
import { describeWithMongoDB } from "./tools/mongodb/mongodbHelpers.js";
43

54
describe("Server integration test", () => {
@@ -16,15 +15,15 @@ describe("Server integration test", () => {
1615
});
1716
},
1817
() => ({
19-
...config,
18+
...defaultTestConfig,
2019
apiClientId: undefined,
2120
apiClientSecret: undefined,
2221
})
2322
);
2423

2524
describe("with atlas", () => {
2625
const integration = setupIntegrationTest(() => ({
27-
...config,
26+
...defaultTestConfig,
2827
apiClientId: "test",
2928
apiClientSecret: "test",
3029
}));
@@ -59,7 +58,7 @@ describe("Server integration test", () => {
5958

6059
describe("with read-only mode", () => {
6160
const integration = setupIntegrationTest(() => ({
62-
...config,
61+
...defaultTestConfig,
6362
readOnly: true,
6463
apiClientId: "test",
6564
apiClientSecret: "test",

tests/integration/tools/atlas/atlasHelpers.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { ObjectId } from "mongodb";
22
import { Group } from "../../../../src/common/atlas/openapi.js";
33
import { ApiClient } from "../../../../src/common/atlas/apiClient.js";
4-
import { setupIntegrationTest, IntegrationTest } from "../../helpers.js";
5-
import { config } from "../../../../src/config.js";
4+
import { setupIntegrationTest, IntegrationTest, defaultTestConfig } from "../../helpers.js";
65

76
export type IntegrationTestFunction = (integration: IntegrationTest) => void;
87

98
export function describeWithAtlas(name: string, fn: IntegrationTestFunction) {
109
const testDefinition = () => {
1110
const integration = setupIntegrationTest(() => ({
12-
...config,
11+
...defaultTestConfig,
1312
apiClientId: process.env.MDB_MCP_API_CLIENT_ID,
1413
apiClientSecret: process.env.MDB_MCP_API_CLIENT_SECRET,
1514
}));

tests/integration/tools/mongodb/mongodbHelpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { MongoCluster } from "mongodb-runner";
22
import path from "path";
33
import fs from "fs/promises";
44
import { MongoClient, ObjectId } from "mongodb";
5-
import { getResponseContent, IntegrationTest, setupIntegrationTest } from "../../helpers.js";
6-
import { config, UserConfig } from "../../../../src/config.js";
5+
import { getResponseContent, IntegrationTest, setupIntegrationTest, defaultTestConfig } from "../../helpers.js";
6+
import { UserConfig } from "../../../../src/config.js";
77

88
interface MongoDBIntegrationTest {
99
mongoClient: () => MongoClient;
@@ -14,7 +14,7 @@ interface MongoDBIntegrationTest {
1414
export function describeWithMongoDB(
1515
name: string,
1616
fn: (integration: IntegrationTest & MongoDBIntegrationTest & { connectMcpClient: () => Promise<void> }) => void,
17-
getUserConfig: (mdbIntegration: MongoDBIntegrationTest) => UserConfig = () => config,
17+
getUserConfig: (mdbIntegration: MongoDBIntegrationTest) => UserConfig = () => defaultTestConfig,
1818
describeFn = describe
1919
) {
2020
describeFn(name, () => {

0 commit comments

Comments
 (0)