Files
kuber/tests/command/validation.test.ts
T

29 lines
916 B
TypeScript

import { describe, expect, test } from "bun:test";
import { db } from "../../command/db";
import { exec } from "../../command/exec";
type RunnableCommand = {
run?: (context: { args: { _: string[] } }) => Promise<unknown>;
subCommands?: Record<string, RunnableCommand>;
};
describe("CLI argument validation", () => {
test("exec requires a deployment", async () => {
await expect(
(exec as RunnableCommand).run?.({ args: { _: [] } }),
).rejects.toThrow("Deployment name is required");
});
test("exec requires a command", async () => {
await expect(
(exec as RunnableCommand).run?.({ args: { _: ["app"] } }),
).rejects.toThrow("Command is required");
});
test("database credentials require a service", async () => {
await expect(
(db as RunnableCommand).subCommands?.creds?.run?.({ args: { _: [] } }),
).rejects.toThrow("Service name is required");
});
});