Skip to content

Commit 76e0068

Browse files
committed
fix: tests
1 parent 22aac5a commit 76e0068

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/integration/tools/atlas/clusters.test.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Session } from "../../../../src/session.js";
22
import { expectDefined } from "../../helpers.js";
33
import { describeWithAtlas, withProject, randomId } from "./atlasHelpers.js";
4+
import { ClusterDescription20240805 } from "../../../../src/common/atlas/openapi.js";
45
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
56

67
function sleep(ms: number) {
@@ -33,7 +34,12 @@ async function deleteAndWaitCluster(session: Session, projectId: string, cluster
3334
}
3435
}
3536

36-
async function waitClusterState(session: Session, projectId: string, clusterName: string, state: string) {
37+
async function waitCluster(
38+
session: Session,
39+
projectId: string,
40+
clusterName: string,
41+
check: (cluster: ClusterDescription20240805) => boolean | Promise<boolean>
42+
) {
3743
while (true) {
3844
const cluster = await session.apiClient.getCluster({
3945
params: {
@@ -43,7 +49,7 @@ async function waitClusterState(session: Session, projectId: string, clusterName
4349
},
4450
},
4551
});
46-
if (cluster?.stateName === state) {
52+
if (await check(cluster)) {
4753
return;
4854
}
4955
await sleep(1000);
@@ -142,7 +148,12 @@ describeWithAtlas("clusters", (integration) => {
142148
describe("atlas-connect-cluster", () => {
143149
beforeAll(async () => {
144150
const projectId = getProjectId();
145-
await waitClusterState(integration.mcpServer().session, projectId, clusterName, "IDLE");
151+
await waitCluster(integration.mcpServer().session, projectId, clusterName, (cluster) => {
152+
return (
153+
cluster.stateName === "IDLE" &&
154+
(cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard) !== undefined
155+
);
156+
});
146157
await integration.mcpServer().session.apiClient.createProjectIpAccessList({
147158
params: {
148159
path: {

0 commit comments

Comments
 (0)