import { describe, expect, it } from "vitest"; import { resolveTestRunPlan } from "./resolve-test-run-plan.ts"; import type { ProjectProbe } from "../ports/project-probe.ts"; function probeWithExistingPaths(existingPaths: string[]): ProjectProbe { const existing = new Set(existingPaths); return { async exists(path: string): Promise { return existing.has(path); }, }; } describe("resolveTestRunPlan", () => { const cwd = "/workspace/service"; it("resolves the default Go test plan for a Go module", async () => { const plan = await resolveTestRunPlan({ cwd, argsTail: "", probe: probeWithExistingPaths(["/workspace/service/go.mod"]), }); expect(plan).toMatchObject({ language: "go", cwd, command: "go", args: ["test", "-race", "./..."], displayCommand: "go test -race ./...", }); }); it("resolves tagged Go test plans for a Go workspace", async () => { const plan = await resolveTestRunPlan({ cwd, argsTail: "--tags contract,e2e", probe: probeWithExistingPaths(["/workspace/service/go.work"]), }); expect(plan).toMatchObject({ language: "go", cwd, command: "go", args: ["test", "-race", "-tags=contract,e2e", "./..."], displayCommand: "go test -race -tags=contract,e2e ./...", }); }); it("fails with a useful error when the repository is not recognized", async () => { await expect( resolveTestRunPlan({ cwd, argsTail: "", probe: probeWithExistingPaths([]), }), ).rejects.toThrow(/unsupported project/i); }); });