Skip to content

refactor(fleetreconcile): make the reconcile gate shell testable and cover its exit paths - #593

Merged
joshua-temple merged 1 commit into
mainfrom
test/fleetreconcile-gate-testability
Jul 16, 2026
Merged

joshua-temple merged 1 commit into
mainfrom
test/fleetreconcile-gate-testability

Conversation

@joshua-temple

Copy link
Copy Markdown
Collaborator

The fleet-reconcile gate binary's run() took an *os.File and called os.Exit(1) mid-function, leaving flag validation, JSONL ledger parsing, and the gate-failed exit path with no regression coverage (the untestable-CLI-shell class that previously shipped inert).

Refactor for testability with NO behavior change: run() now takes an io.Writer and returns (exitCode, err); os.Exit(code) lives only in main(); parseLedger(io.Reader) is extracted for in-memory testing. Exit codes (0 pass / 1 gate-fail / 2 tool-error), error strings, stderr prefix, and report output are byte-identical.

Adds hermetic table tests asserting exit code + message per branch (flag validation, input/ledger parse errors, gate PASS, gate FAIL) and a parseLedger table. Maintainer tooling, unit-only.

Verification: build/-race/lint green, 3081 tests; new branch tests fail-before/pass-after the refactor.

…cover its exit paths

Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
@joshua-temple
joshua-temple merged commit be880a7 into main Jul 16, 2026
21 checks passed
@joshua-temple
joshua-temple deleted the test/fleetreconcile-gate-testability branch July 16, 2026 01:32
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.

1 participant