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
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1/workspaces/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { listDeploymentVariablesByDeploymentRouter } from "./deployment-variable
const PLAN_TTL_MS = 60 * 60 * 1000;

const parseSelector = (raw: string | null | undefined): string | undefined => {
if (raw == null || raw === "false") return undefined;
if (raw == null) return undefined;
return raw;
Comment on lines +25 to 26
};

Expand Down
62 changes: 62 additions & 0 deletions e2e/tests/api/deployments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,68 @@ test.describe("Deployment API", () => {
);
});

test("should return resourceSelector verbatim when written as 'false'", async ({
api,
workspace,
}) => {
const name = `deploy-rs-false-${faker.string.alphanumeric(8)}`;
const createRes = await api.POST(
"/v1/workspaces/{workspaceId}/deployments",
{
params: { path: { workspaceId: workspace.id } },
body: { name, slug: name, resourceSelector: "false" },
},
);
expect(createRes.response.status).toBe(202);
const deploymentId = createRes.data!.id;

const getRes = await api.GET(
"/v1/workspaces/{workspaceId}/deployments/{deploymentId}",
{
params: { path: { workspaceId: workspace.id, deploymentId } },
},
);

expect(getRes.response.status).toBe(200);
expect(getRes.data!.deployment.resourceSelector).toBe("false");

await api.DELETE(
"/v1/workspaces/{workspaceId}/deployments/{deploymentId}",
{ params: { path: { workspaceId: workspace.id, deploymentId } } },
);
});

test("should default resourceSelector to 'false' when omitted on create", async ({
api,
workspace,
}) => {
const name = `deploy-rs-omit-${faker.string.alphanumeric(8)}`;
const createRes = await api.POST(
"/v1/workspaces/{workspaceId}/deployments",
{
params: { path: { workspaceId: workspace.id } },
body: { name, slug: name },
},
);
expect(createRes.response.status).toBe(202);
const deploymentId = createRes.data!.id;

const getRes = await api.GET(
"/v1/workspaces/{workspaceId}/deployments/{deploymentId}",
{
params: { path: { workspaceId: workspace.id, deploymentId } },
},
);

expect(getRes.response.status).toBe(200);
expect(getRes.data!.deployment.resourceSelector).toBe("false");

await api.DELETE(
"/v1/workspaces/{workspaceId}/deployments/{deploymentId}",
{ params: { path: { workspaceId: workspace.id, deploymentId } } },
);
});

test("should create a deployment with a custom jobAgentSelector", async ({
api,
workspace,
Expand Down
Loading