Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions tests/integration/tools/atlas/accessLists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ describeWithAtlas("ip access lists", (integration) => {
const apiClient = integration.mcpServer().session.apiClient;

const projectId = getProjectId();

for (const value of values) {
await apiClient.deleteProjectIpAccessList({
params: {
path: {
groupId: projectId,
entryValue: value,
if (projectId) {
// projectId may be empty if beforeAll failed.
for (const value of values) {
await apiClient.deleteProjectIpAccessList({
params: {
path: {
groupId: projectId,
entryValue: value,
},
},
},
});
});
}
}
});

Expand Down
22 changes: 12 additions & 10 deletions tests/integration/tools/atlas/atlasHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio

try {
const group = await createProject(apiClient);
projectId = group.id || "";
projectId = group.id;
} catch (error) {
console.error("Failed to create project:", error);
throw error;
Expand All @@ -50,14 +50,16 @@ export function withProject(integration: IntegrationTest, fn: ProjectTestFunctio

afterAll(async () => {
const apiClient = integration.mcpServer().session.apiClient;

await apiClient.deleteProject({
params: {
path: {
groupId: projectId,
if (projectId) {
// projectId may be empty if beforeAll failed.
await apiClient.deleteProject({
params: {
path: {
groupId: projectId,
},
},
},
});
});
}
});

const args = {
Expand Down Expand Up @@ -90,7 +92,7 @@ export function parseTable(text: string): Record<string, string>[] {

export const randomId = new ObjectId().toString();

async function createProject(apiClient: ApiClient): Promise<Group> {
async function createProject(apiClient: ApiClient): Promise<Group & Required<Pick<Group, "id">>> {
const projectName: string = `testProj-` + randomId;

const orgs = await apiClient.listOrganizations();
Expand All @@ -109,5 +111,5 @@ async function createProject(apiClient: ApiClient): Promise<Group> {
throw new Error("Failed to create project");
}

return group;
return group as Group & Required<Pick<Group, "id">>;
}
8 changes: 4 additions & 4 deletions tests/integration/tools/atlas/clusters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ describeWithAtlas("clusters", (integration) => {

afterAll(async () => {
const projectId = getProjectId();

const session: Session = integration.mcpServer().session;

await deleteAndWaitCluster(session, projectId, clusterName);
if (projectId) {
const session: Session = integration.mcpServer().session;
await deleteAndWaitCluster(session, projectId, clusterName);
}
});

describe("atlas-create-free-cluster", () => {
Expand Down
8 changes: 7 additions & 1 deletion tests/integration/tools/atlas/dbUsers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ describeWithAtlas("db users", (integration) => {
};

afterEach(async () => {
const projectId = getProjectId();
if (!projectId) {
// projectId may be empty if beforeAll failed
return;
}

try {
await integration.mcpServer().session.apiClient.deleteDatabaseUser({
params: {
path: {
groupId: getProjectId(),
groupId: projectId,
username: userName,
databaseName: "admin",
},
Expand Down
Loading