Skip to content
Open
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
48 changes: 48 additions & 0 deletions test/generated-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,54 @@ describe("generated public commands", () => {
expect(result.data).toEqual(quotas);
});

test("operations.wait preserves its literal custom method suffix", async () => {
let received: Request | undefined;
const operation = clusterOperation();
const result = await runGenerated(
"operations.wait",
["--input", "-"],
JSON.stringify({ path: { id: "op:123" }, query: { timeout: 60 } }),
(input, init) => {
received = new Request(input, init);
return Promise.resolve(Response.json(operation));
},
);

expect(result.data).toEqual(operation);
expect(received?.method).toBe("POST");
expect(received?.url).toBe(
"https://api.akua.dev/v1/operations/op%3A123:wait?timeout=60",
);
});

test("clusters.refreshCapabilities preserves a nested literal custom method suffix", async () => {
let received: Request | undefined;
const operation = clusterOperation();
const result = await runGenerated(
"clusters.refreshCapabilities",
["--input", "-"],
JSON.stringify({
path: { id: "clu:123" },
headers: {
"akua-context": "ws_123",
"idempotency-key": "refresh-once",
},
}),
(input, init) => {
received = new Request(input, init);
return Promise.resolve(Response.json(operation, { status: 202 }));
},
);

expect(result.data).toEqual(operation);
expect(received?.method).toBe("POST");
expect(received?.url).toBe(
"https://api.akua.dev/v1/clusters/clu%3A123/capabilities:refresh",
);
expect(received?.headers.get("akua-context")).toBe("ws_123");
expect(received?.headers.get("idempotency-key")).toBe("refresh-once");
});

test("clusters.resume builds the literal :action-suffixed request path", async () => {
let received: Request | undefined;
const operation = clusterOperation();
Expand Down
Loading