Files
kuber/tests/command/up.test.ts
T
dmgnr 6c8c8e0c1b feat: implement rollback command for deployments
- Added a new `rollback` command to roll back deployments to their previous release.
- Introduced `findRollbackCandidates` and `rollbackDeployment` functions to handle rollback logic.
- Updated CLI command definitions to include the new `rollback` command with an alias.
- Enhanced deployment conversion to use resolved images for buildable services.
- Introduced a new `graph` module to visualize Kubernetes resources and their relationships.
- Added tests for the new rollback functionality and graph rendering.
- Updated package version to 1.3.0.
2026-08-30 23:47:38 +07:00

65 lines
2.0 KiB
TypeScript

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: [], images: {} });
});
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);
});
});