Skip to content

Test the CLI through cmd.Run, capturing the (stdout, stderr, exit code) triple - #62

Open
MPV wants to merge 1 commit into
masterfrom
claude/e2e-approvals-triple
Open

Test the CLI through cmd.Run, capturing the (stdout, stderr, exit code) triple#62
MPV wants to merge 1 commit into
masterfrom
claude/e2e-approvals-triple

Conversation

@MPV

@MPV MPV commented Aug 2, 2026

Copy link
Copy Markdown
Owner

What

The whole behavioral golden suite in approvals/ now runs through cmd.Run — the real CLI entry point (#63) — via a single verify(args, stdin) helper, and approves each scenario's (stdout, stderr, exit code) triple as three per-stream golden files. In-process (no subprocess/go build), all in approvals/kir_test.go, no new dependency.

Why one seam

Run is the actual public contract. Testing every scenario through it means:

  • the goldens capture exactly what the tool emits — the trailing newline on stdout, the error: prefix on stderr, and the exit code — not a processor-level approximation;
  • tests assert behaviour, not an internal function, so refactoring internals doesn't churn them;
  • one uniform convention across the suite.

Granular, per-layer localization stays where it belongs — the k8s / yamlparser / processor / fileutil unit tests. This package is the behavioral golden layer.

What changed from the processor-level version

  • +9 exitcode goldens (the workload/error/multi scenarios), all 0.
  • 8 stdout goldens gain the real trailing newline (fmt.Fprintln vs strings.Join).
  • TestError's stderr gains the CLI's error: log prefix.

Scenarios

Seven workload kinds, a Service (error), a multi-document file, and the CLI-only cases: stdin (-), a missing path, and no-args usage.

Scope

Standalone, additive, off master. -race/vet/gofmt/go mod tidy all clean. Supersedes the testscript track (#61) if you prefer staying approvals-native.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC

@MPV
MPV force-pushed the claude/e2e-approvals-triple branch 2 times, most recently from fbed092 to e9001a9 Compare August 2, 2026 07:26
@MPV MPV changed the title Add an approvals-based e2e layer capturing the output triple Add an approvals-based e2e layer with whole-scenario goldens Aug 2, 2026
@MPV
MPV force-pushed the claude/e2e-approvals-triple branch from e9001a9 to f5f9422 Compare August 2, 2026 08:05
@MPV MPV changed the title Add an approvals-based e2e layer with whole-scenario goldens Approve the CLI (stdout, stderr, exit code) triple in approvals/ Aug 2, 2026
@MPV
MPV force-pushed the claude/e2e-approvals-triple branch 2 times, most recently from cb6bc2f to c5bbc9a Compare August 2, 2026 08:18
Route the whole behavioral golden suite through cmd.Run — the real entry
point (#63) — via one verify(args, stdin) helper, and approve each
scenario's (stdout, stderr, exit code) triple as three golden files.

Every test now exercises the actual CLI seam rather than the internal
processor.ProcessFile, so the goldens capture exactly what the tool emits
(the trailing newline on stdout, the "error:" prefix on stderr, and the
exit code). Granular, per-layer coverage stays in the
k8s/yamlparser/processor/fileutil unit tests; this package is the
behavioral golden layer.

Scenarios: the seven workload kinds, a Service (error), a multi-document
file, plus the CLI-only cases stdin, a missing path, and no-args usage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pc6NAURAqjU4LYJx93tgSC
@MPV
MPV force-pushed the claude/e2e-approvals-triple branch from c5bbc9a to 59e4fe7 Compare August 3, 2026 08:25
@MPV MPV changed the title Approve the CLI (stdout, stderr, exit code) triple in approvals/ Test the CLI through cmd.Run, capturing the (stdout, stderr, exit code) triple Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants