Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions tests/integration/tools/atlas/atlasHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,25 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio
}
});

afterAll(async () => {
afterAll(() => {
if (!projectId) {
return;
}

const apiClient = integration.mcpServer().session.apiClient;
if (projectId) {
// projectId may be empty if beforeAll failed.
await apiClient.deleteProject({

// send the delete request and ignore errors
apiClient
.deleteProject({
params: {
path: {
groupId: projectId,
},
},
})
.catch((error) => {
console.log("Failed to delete project:", error);
});
}
});

const args = {
Expand Down
14 changes: 12 additions & 2 deletions tests/integration/tools/atlas/clusters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

async function deleteAndWaitCluster(session: Session, projectId: string, clusterName: string): Promise<void> {
async function deleteCluster(
session: Session,
projectId: string,
clusterName: string,
wait: boolean = false
): Promise<void> {
await session.apiClient.deleteCluster({
params: {
path: {
Expand All @@ -17,6 +22,11 @@ async function deleteAndWaitCluster(session: Session, projectId: string, cluster
},
},
});

if (!wait) {
return;
}

while (true) {
try {
await session.apiClient.getCluster({
Expand Down Expand Up @@ -64,7 +74,7 @@ describeWithAtlas("clusters", (integration) => {
const projectId = getProjectId();
if (projectId) {
const session: Session = integration.mcpServer().session;
await deleteAndWaitCluster(session, projectId, clusterName);
await deleteCluster(session, projectId, clusterName);
}
});

Expand Down
Loading