Skip to content

test(cli/output): raise coverage from 0% to 82%#22

Merged
kevinelliott merged 1 commit intomainfrom
test/cli-systray-coverage
Apr 21, 2026
Merged

test(cli/output): raise coverage from 0% to 82%#22
kevinelliott merged 1 commit intomainfrom
test/cli-systray-coverage

Conversation

@kevinelliott
Copy link
Copy Markdown
Owner

Summary

`internal/cli/output` had no tests despite being the shared output layer for every CLI command. This PR adds focused unit tests that bring the package to 82% statement coverage.

Coverage changes

package before after
`internal/cli/output` 0.0% 82.0%

Test files added

  • `colors_test.go`: `NoColor` precedence (flag > NO_COLOR env > cfg), Printer routing (Success/Info/Print/Printf/Println to stdout; Warning/Error to stderr), no-color vs default `Styles` variants, and the `Format*` helpers (Status, Version, Badge, AgentName, Method, Header).
  • `spinner_test.go`: non-TTY Start/Stop are no-ops (no ANSI in buffer), Success/Error/Warning/Info icon rendering, `NO_COLOR` env propagation, double-stop safety, custom frames/interval options, and the `isTerminal()` helper against `bytes.Buffer` / `io.Discard`.
  • `table_test.go`: `VisibleWidth` (ASCII, empty, ANSI-stripped, multi-byte runes, mixed), `Render` (empty early-return, basic columns, ANSI headers don't bloat width, custom padding widens output, rows without headers).

No production code changes.

Test plan

  • `go test ./internal/cli/output/... -race -cover` → 82% coverage, all pass
  • `make lint` clean

🤖 Generated with Claude Code

internal/cli/output had no tests despite being the shared output layer
for every CLI command. Adds focused unit tests for the three files:

- colors_test.go: NoColor precedence (flag > NO_COLOR env > cfg), Printer
  routing (Success/Info/Print/Printf/Println to stdout; Warning/Error to
  stderr), no-color vs default Styles variants, and the Format* helpers
  (Status, Version, Badge, AgentName, Method, Header).
- spinner_test.go: non-TTY Start/Stop are no-ops (no ANSI in buffer),
  Success/Error/Warning/Info icon rendering, NO_COLOR env propagation,
  double-stop safety, custom frames/interval options, and the
  isTerminal() helper against bytes.Buffer / io.Discard.
- table_test.go: VisibleWidth (ASCII, empty, ANSI-stripped, multi-byte
  runes, mixed), Render (empty early-return, basic columns, ANSI
  headers don't bloat width, custom padding widens output, rows without
  headers).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 21, 2026 09:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds unit tests for internal/cli/output, the shared CLI output layer, to substantially increase statement coverage without changing production behavior.

Changes:

  • Add tests for color/no-color resolution and Printer output routing/style helpers.
  • Add tests for Spinner non-TTY behavior, variants, options, and terminal detection helper.
  • Add tests for Table rendering and VisibleWidth (ANSI stripping + rune width).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/cli/output/colors_test.go Covers NoColor/Printer behaviors and Styles formatting helpers.
internal/cli/output/spinner_test.go Covers non-TTY spinner semantics, icons, env propagation, options, and isTerminal().
internal/cli/output/table_test.go Covers VisibleWidth and core Table.Render output scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +54 to +62
// Column count: each non-empty line should contain both columns.
for _, line := range strings.Split(strings.TrimSpace(out), "\n") {
if line == "" {
continue
}
// Rough alignment sanity: the longest row (claude-code = 11 chars)
// should leave at least padding+1 spaces before the second column
// for shorter rows.
_ = line
Comment on lines +27 to +31
s.Start()
// Give the goroutine a chance to emit frames — there should be NONE
// because Start is a no-op on non-TTY output.
time.Sleep(30 * time.Millisecond)
s.Stop()
@kevinelliott kevinelliott merged commit 0c578ab into main Apr 21, 2026
19 checks passed
@kevinelliott kevinelliott deleted the test/cli-systray-coverage branch April 21, 2026 09:08
kevinelliott added a commit that referenced this pull request Apr 21, 2026
Promote the Unreleased section to 1.2.0 and capture the UX /
operability work landed since v1.1.0:

- #20 install/update progress streaming with -v
- #21 gRPC server wire-up in helper
- #22, #26 test coverage (cli/output 0→82%, systray 0.2→3.2%)
- #24 RefreshOnStart field removal
- #27 bubbles v0.21 -> v1.0
- #28 go:embed baseline catalog (fresh `go install` works offline)
- #29 pkg/logging slog wrapper wired into main and grpc recovery

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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