Skip to content

test(cli): comprehensive behavior + contract test suite (79 cases)#401

Merged
ohdearquant merged 1 commit into
mainfrom
slice/v022/02-cli-tests
May 25, 2026
Merged

test(cli): comprehensive behavior + contract test suite (79 cases)#401
ohdearquant merged 1 commit into
mainfrom
slice/v022/02-cli-tests

Conversation

@ohdearquant
Copy link
Copy Markdown
Owner

Summary

Slice 2/9 from PR #399 (v022-polish show).

CLI test surface went from 0 → 79 black-box subprocess tests with golden file comparisons. All Deno/TypeScript — no Rust changes.

What's added

  • cli/tests/helpers.ts — subprocess runner, golden comparator, JSON shape validator, makeTempRepo() fixture
  • cli/tests/behavior/exit_code_test.ts (31 cases) — exit 0/1 for all flags, unknown commands, kg/pack/auth subcommands
  • cli/tests/behavior/error_test.ts (13 cases) — error messages, --help hints, invalid NDJSON, out-of-repo
  • cli/tests/behavior/parse_test.ts (21 cases) — flag parsing for stats/validate/doctor/log/diff
  • cli/tests/contract/help_test.ts (17 cases) — golden file comparisons for --help
  • cli/tests/contract/output_test.ts (8 cases) — version semver, kg stats/validate/doctor JSON shape
  • Golden files for help text at all command groups
  • deno.json tasks: test:behavior and test:contract

Dependencies

None. TypeScript-only. Mergeable independently.

Test plan

  • deno task test:behavior passes
  • deno task test:contract passes
  • CI green

- Add cli/tests/helpers.ts with subprocess runner, golden file comparator,
  JSON shape validator, and makeTempRepo() fixture with valid KG structure
- Add cli/tests/behavior/exit_code_test.ts (31 cases): exit 0/1 for all
  top-level flags, unknown commands, kg/pack/auth subcommands, in-repo ops
- Add cli/tests/behavior/error_test.ts (13 cases): error messages, --help
  hints, not-implemented stubs, invalid NDJSON, out-of-repo commands
- Add cli/tests/behavior/parse_test.ts (21 cases): flag parsing for stats
  (--json), validate (--format json, --quiet, --no-rules), doctor (--json),
  log (-n, --json), diff (--json, --name-only), pack stubs
- Add cli/tests/contract/help_test.ts (17 cases): golden file comparisons
  for --help at top-level, kg, pack, auth groups; content assertions
- Add cli/tests/contract/output_test.ts (8 cases): version semver check,
  kg stats --json shape, kg validate --format json shape, kg doctor --json
- Add golden files: help_toplevel.txt, help_kg.txt, help_pack.txt, help_auth.txt
- Add deno.json tasks: test:behavior and test:contract

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ohdearquant
Copy link
Copy Markdown
Owner Author

Self-review (lambda:khive)

Verdict: APPROVE

Checked

  • 79 tests across 5 files: behavior/{error,exit_code,parse}_test.ts + contract/{help,output}_test.ts
  • 4 golden files for help text at top-level, kg, pack, auth
  • helpers.ts provides runCli, assertGolden, makeTempRepo — proper fixture infrastructure
  • deno.json adds test:behavior and test:contract tasks
  • Tests cover exit codes, error messages, flag parsing, JSON shape contracts
  • CI green on both macos + ubuntu

Suggestions (non-blocking)

  • Eventually wire kg commit, kg sync, kg status tests (recon §7 noted these as uncovered) — fine as follow-up.

Recommend merge once Ocean approves the slice batch.

@ohdearquant ohdearquant merged commit 30e2862 into main May 25, 2026
3 checks passed
@ohdearquant ohdearquant deleted the slice/v022/02-cli-tests branch May 25, 2026 15:42
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