Files
kuber/tests/command/startup.test.ts
T
2026-10-07 10:33:21 +00:00

42 lines
1.3 KiB
TypeScript

import { expect, test } from "bun:test";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
test("init help starts in an empty directory without requiring Compose", async () => {
const cwd = await mkdtemp(join(tmpdir(), "kuber-startup-test-"));
try {
const process = Bun.spawn(
["bun", resolve(import.meta.dir, "../../index.ts"), "init", "--help"],
{ cwd, stdout: "pipe", stderr: "pipe" },
);
const [status, out, err] = await Promise.all([
process.exited,
new Response(process.stdout).text(),
new Response(process.stderr).text(),
]);
expect(status).toBe(0);
expect(out + err).toContain("init");
expect(out + err).not.toContain("Compose file cannot be found");
} finally {
await rm(cwd, { recursive: true, force: true });
}
});
test.each(["users", "ci"])(
"hidden %s command remains available to CLI help",
async (command) => {
const process = Bun.spawn(
["bun", resolve(import.meta.dir, "../../index.ts"), command, "--help"],
{ stdout: "pipe", stderr: "pipe" },
);
const [status, out, err] = await Promise.all([
process.exited,
new Response(process.stdout).text(),
new Response(process.stderr).text(),
]);
expect(status).toBe(0);
expect(out + err).toContain(command);
},
);