Skip to content

Commit 3743557

Browse files
Fix integration test when there's not deployment available
1 parent 9e4e3c5 commit 3743557

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

tests/integration/server.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ describe("Server integration test", () => {
1111
expectDefined(tools);
1212
expect(tools.tools.length).toBeGreaterThan(0);
1313

14-
const atlasTools = tools.tools.filter((tool) => tool.name.startsWith("atlas-") && !tool.name.startsWith("atlas-local-"));
14+
const atlasTools = tools.tools.filter(
15+
(tool) => tool.name.startsWith("atlas-") && !tool.name.startsWith("atlas-local-")
16+
);
1517
expect(atlasTools.length).toBeLessThanOrEqual(0);
1618
});
1719
},

tests/integration/tools/atlas-local/listDeployments.test.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "../../helpers.js";
88
import { describe, expect, it } from "vitest";
99

10-
const isMacOSInGitHubActions = process.platform === 'darwin' && process.env.GITHUB_ACTIONS === 'true'
10+
const isMacOSInGitHubActions = process.platform === "darwin" && process.env.GITHUB_ACTIONS === "true";
1111

1212
describe("atlas-local-list-deployments", () => {
1313
const integration = setupIntegrationTest(
@@ -21,11 +21,14 @@ describe("atlas-local-list-deployments", () => {
2121
expectDefined(listDeployments);
2222
});
2323

24-
it.skipIf(!isMacOSInGitHubActions)("[MacOS in GitHub Actions] should not have the atlas-local-list-deployments tool", async () => {
25-
const { tools } = await integration.mcpClient().listTools();
26-
const listDeployments = tools.find((tool) => tool.name === "atlas-local-list-deployments");
27-
expect(listDeployments).toBeUndefined();
28-
});
24+
it.skipIf(!isMacOSInGitHubActions)(
25+
"[MacOS in GitHub Actions] should not have the atlas-local-list-deployments tool",
26+
async () => {
27+
const { tools } = await integration.mcpClient().listTools();
28+
const listDeployments = tools.find((tool) => tool.name === "atlas-local-list-deployments");
29+
expect(listDeployments).toBeUndefined();
30+
}
31+
);
2932

3033
it.skipIf(isMacOSInGitHubActions)("should have correct metadata", async () => {
3134
const { tools } = await integration.mcpClient().listTools();
@@ -42,10 +45,17 @@ describe("atlas-local-list-deployments", () => {
4245
arguments: {},
4346
});
4447
const elements = getResponseElements(response.content);
45-
expect(elements).toHaveLength(2);
46-
expect(elements[0]?.text).toMatch(/Found \d+ deployments/);
47-
expect(elements[1]?.text).toContain(
48-
"Deployment Name | State | MongoDB Version\n----------------|----------------|----------------\n"
49-
);
48+
expect(elements.length).toBeGreaterThanOrEqual(1);
49+
50+
if (elements.length === 1) {
51+
expect(elements[0]?.text).toContain("No deployments found.");
52+
}
53+
54+
if (elements.length > 1) {
55+
expect(elements[0]?.text).toMatch(/Found \d+ deployments/);
56+
expect(elements[1]?.text).toContain(
57+
"Deployment Name | State | MongoDB Version\n----------------|----------------|----------------\n"
58+
);
59+
}
5060
});
5161
});

0 commit comments

Comments
 (0)