Skip to content

test: unblock progress/runner coverage and extend updater/prompt tests#67

Open
DecampsRenan wants to merge 1 commit into
mainfrom
claude/test-coverage-gaps-rrcRQ
Open

test: unblock progress/runner coverage and extend updater/prompt tests#67
DecampsRenan wants to merge 1 commit into
mainfrom
claude/test-coverage-gaps-rrcRQ

Conversation

@DecampsRenan
Copy link
Copy Markdown
Owner

Summary

Addresses the three test-coverage gaps called out as follow-ups: the updater HTTP path, the prompt success paths, and the progress/runner packages that couldn't be tested because of their transitive ALSA dependency.

Updater — inject Downloader interface

  • New Downloader interface and HTTPDownloader default implementation.
  • Execute() now takes a Downloader, so tests can feed canned archive bytes or network errors without hitting the network.
  • Tests added: homebrew refusal, download error propagation, invalid archive, missing binary in archive, successful replace, missing target, plus HTTPDownloader success / non-200 / network error paths via httptest.
  • Coverage: ~47% → 72.6%.

Audio — split CGO playback into its own package

  • Moved the beep/oto code (Player, PlayMusicAndWait, PlaySound, embedded .mp3 files) from internal/audio into a new internal/audio/playback package.
  • internal/audio now only contains the pure-Go launchers (StartVibes, PlayNotification, NotificationSound) — importing it no longer pulls in ALSA.
  • cmd/root.go wires the hidden _play-music / _play-sound subcommands to the new playback package.
  • This unblocks progress and runner tests in environments where CGO is enabled but libasound isn't installed.

Progress — new model tests

  • Added internal/progress/model_test.go covering the ring buffer (addLine), the Update state transitions (output line / done / timer / window size), the three View render modes (running / success / failure / truncation), and listenCh channel behavior.
  • Coverage: 0% → 38.1%.

Prompt — extract pure helpers, test them

  • Extracted findDetectionByPM, truncateCmd, and scriptOptionLabel from the TTY-bound flows so they can be unit-tested without a PTY.
  • Select and SelectScript now delegate to those helpers; behavior is identical.
  • Coverage: 13.3% → 26.7%.

Test plan

  • CGO_ENABLED=0 go test ./... — all green
  • go test ./internal/audio ./internal/progress ./internal/runner ./internal/prompt ./internal/updater with default CGO — all green (previously progress/runner failed to build)
  • Verify on macOS that _play-music and _play-sound still work end-to-end after the audio package split
  • Verify spm upgrade still downloads a release through HTTPDownloader

- updater: inject Downloader interface so Execute() can be tested without
  live HTTP. Adds tests for homebrew refusal, download errors, invalid
  archives, and successful binary replacement. Coverage 47% -> 72.6%.
- audio: split CGO playback code into internal/audio/playback so
  progress/runner no longer transitively depend on ALSA at test time.
  Fixes build failures in test envs where cgo is enabled without libasound.
- progress: add model tests for addLine ring buffer, Update transitions
  (output/done/timer/window-size), and View rendering. 0% -> 38.1%.
- prompt: extract findDetectionByPM, truncateCmd, and scriptOptionLabel
  helpers with unit tests. 13.3% -> 26.7%.
@DecampsRenan DecampsRenan marked this pull request as ready for review May 4, 2026 07:55
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