Skip to content

Commit ceb06b0

Browse files
committed
feat: test pause/restore
1 parent bb666a3 commit ceb06b0

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

packages/mcp-server-supabase/src/server.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ async function setup(options: SetupOptions = {}) {
8585
const [textContent] = content;
8686

8787
if (!textContent) {
88-
throw new Error('tool result content is missing');
88+
return undefined;
8989
}
9090

9191
if (textContent.type !== 'text') {
@@ -215,6 +215,32 @@ describe('tools', () => {
215215
});
216216
});
217217

218+
test('pause project', async () => {
219+
const { callTool } = await setup();
220+
const project = mockProjects.values().next().value!;
221+
await callTool({
222+
name: 'pause_project',
223+
arguments: {
224+
project_id: project.id,
225+
},
226+
});
227+
228+
expect(project.status).toEqual('INACTIVE');
229+
});
230+
231+
test('restore project', async () => {
232+
const { callTool } = await setup();
233+
const project = mockProjects.values().next().value!;
234+
await callTool({
235+
name: 'restore_project',
236+
arguments: {
237+
project_id: project.id,
238+
},
239+
});
240+
241+
expect(project.status).toEqual('ACTIVE_HEALTHY');
242+
});
243+
218244
test('get project url', async () => {
219245
const { callTool } = await setup();
220246
const project = mockProjects.values().next().value!;

packages/mcp-server-supabase/test/mocks.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,36 @@ export const mockManagementApi = [
9898
return HttpResponse.json(projectResponse);
9999
}),
100100

101+
http.post<{ projectId: string }>(
102+
`${API_URL}/v1/projects/:projectId/pause`,
103+
({ params }) => {
104+
const project = mockProjects.get(params.projectId);
105+
if (!project) {
106+
return HttpResponse.json(
107+
{ error: 'Project not found' },
108+
{ status: 404 }
109+
);
110+
}
111+
project.status = 'INACTIVE';
112+
return HttpResponse.json(project.details);
113+
}
114+
),
115+
116+
http.post<{ projectId: string }>(
117+
`${API_URL}/v1/projects/:projectId/restore`,
118+
({ params }) => {
119+
const project = mockProjects.get(params.projectId);
120+
if (!project) {
121+
return HttpResponse.json(
122+
{ error: 'Project not found' },
123+
{ status: 404 }
124+
);
125+
}
126+
project.status = 'ACTIVE_HEALTHY';
127+
return HttpResponse.json(project.details);
128+
}
129+
),
130+
101131
http.get(`${API_URL}/v1/organizations`, () => {
102132
return HttpResponse.json(mockOrgs);
103133
}),

0 commit comments

Comments
 (0)