feat: improve deployment workflows
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { getDeploymentNames, mergeServiceEnv } from "../../command/up";
|
||||
import { buildServices, imageDigestChanged } from "../../lib/build";
|
||||
import type { KubernetesResource } from "../../lib/convert";
|
||||
import type { ComposeSpecification } from "../../schema/docker.d";
|
||||
|
||||
describe("up task selection", () => {
|
||||
test("merges generated service environments without dropping providers", () => {
|
||||
expect(
|
||||
mergeServiceEnv(
|
||||
{
|
||||
app: { DATABASE_URL: "postgresql://database" },
|
||||
worker: { EXISTING: "yes" },
|
||||
},
|
||||
{
|
||||
app: { AWS_ACCESS_KEY_ID: "key" },
|
||||
},
|
||||
),
|
||||
).toEqual({
|
||||
app: {
|
||||
DATABASE_URL: "postgresql://database",
|
||||
AWS_ACCESS_KEY_ID: "key",
|
||||
},
|
||||
worker: { EXISTING: "yes" },
|
||||
});
|
||||
});
|
||||
|
||||
test("selects only named Deployment resources for rollout waiting", () => {
|
||||
const resources = [
|
||||
{
|
||||
apiVersion: "apps/v1",
|
||||
kind: "Deployment",
|
||||
metadata: { name: "app" },
|
||||
},
|
||||
{
|
||||
apiVersion: "apps/v1",
|
||||
kind: "Deployment",
|
||||
metadata: {},
|
||||
},
|
||||
{ apiVersion: "v1", kind: "Service", metadata: { name: "app" } },
|
||||
] as KubernetesResource[];
|
||||
expect(getDeploymentNames(resources)).toEqual(["app"]);
|
||||
});
|
||||
|
||||
test("reports no built deployments without invoking build infrastructure", async () => {
|
||||
expect(
|
||||
await buildServices(
|
||||
"project",
|
||||
{
|
||||
services: { app: { image: "nginx:latest" } },
|
||||
} as ComposeSpecification,
|
||||
process.cwd(),
|
||||
),
|
||||
).toEqual({ built: [], changed: [] });
|
||||
});
|
||||
|
||||
test("restarts only for changed or unknown image digests", () => {
|
||||
const digest = `sha256:${"a".repeat(64)}`;
|
||||
expect(imageDigestChanged(digest, digest)).toBe(false);
|
||||
expect(imageDigestChanged(digest, `sha256:${"b".repeat(64)}`)).toBe(true);
|
||||
expect(imageDigestChanged(undefined, digest)).toBe(true);
|
||||
expect(imageDigestChanged(digest, undefined)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user