import { describe, expect, it } from "vite-plus/test"; import { hasDeployChanges, reconcileRootEnvRelayUrl, serializeGithubOutput } from "./deploy.ts"; describe("hasDeployChanges", () => { it("detects resource, binding, and deletion changes", () => { expect(hasDeployChanges({ resources: {}, deletions: {} } as never)).toBe(false); expect( hasDeployChanges({ resources: { api: { action: "create", bindings: [] }, }, deletions: {}, } as never), ).toBe(true); expect( hasDeployChanges({ resources: { api: { action: "noop", bindings: [{ action: "update" }] }, }, deletions: {}, } as never), ).toBe(true); expect( hasDeployChanges({ resources: {}, deletions: { api: { action: "delete", bindings: [] }, }, } as never), ).toBe(true); });}); describe("reconcileRootEnvRelayUrl", () => { it("adds the relay URL to an empty root env file", () => { expect(reconcileRootEnvRelayUrl("", "https://relay.example.test")).toBe( "T3CODE_RELAY_URL=https://relay.example.test\n", ); }); it("preserves unrelated root env entries while replacing a previous relay URL", () => { expect( reconcileRootEnvRelayUrl( "T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_example\nT3CODE_RELAY_URL=https://old.example.test\n", "https://relay.example.test", ), ).toBe( "T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_example\nT3CODE_RELAY_URL=https://relay.example.test\n", ); });}); describe("serializeGithubOutput", () => { it("serializes relay deploy metadata for GitHub Actions outputs", () => { expect( serializeGithubOutput({ changed: false, result: "noop", relay_url: "https://relay.example.test", }), ).toBe("changed=false\nresult=noop\nrelay_url=https://relay.example.test\n"); });});
import { describe, expect, it } from "vite-plus/test";
import { hasDeployChanges, reconcileRootEnvRelayUrl, serializeGithubOutput } from "./deploy.ts";
describe("hasDeployChanges", () => {
it("detects resource, binding, and deletion changes", () => {
expect(hasDeployChanges({ resources: {}, deletions: {} } as never)).toBe(false);
expect(
hasDeployChanges({
resources: {
api: { action: "create", bindings: [] },
},
deletions: {},
} as never),
).toBe(true);
expect(
hasDeployChanges({
resources: {
api: { action: "noop", bindings: [{ action: "update" }] },
},
deletions: {},
} as never),
).toBe(true);
expect(
hasDeployChanges({
resources: {},
deletions: {
api: { action: "delete", bindings: [] },
},
} as never),
).toBe(true);
});
});
describe("reconcileRootEnvRelayUrl", () => {
it("adds the relay URL to an empty root env file", () => {
expect(reconcileRootEnvRelayUrl("", "https://relay.example.test")).toBe(
"T3CODE_RELAY_URL=https://relay.example.test\n",
);
});
it("preserves unrelated root env entries while replacing a previous relay URL", () => {
expect(
reconcileRootEnvRelayUrl(
"T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_example\nT3CODE_RELAY_URL=https://old.example.test\n",
"https://relay.example.test",
),
).toBe(
"T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_example\nT3CODE_RELAY_URL=https://relay.example.test\n",
);
});
});
describe("serializeGithubOutput", () => {
it("serializes relay deploy metadata for GitHub Actions outputs", () => {
expect(
serializeGithubOutput({
changed: false,
result: "noop",
relay_url: "https://relay.example.test",
}),
).toBe("changed=false\nresult=noop\nrelay_url=https://relay.example.test\n");
});
});