test: unblock progress/runner coverage and extend updater/prompt tests#67
Open
DecampsRenan wants to merge 1 commit into
Open
test: unblock progress/runner coverage and extend updater/prompt tests#67DecampsRenan wants to merge 1 commit into
DecampsRenan wants to merge 1 commit into
Conversation
- 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%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
DownloaderinterfaceDownloaderinterface andHTTPDownloaderdefault implementation.Execute()now takes aDownloader, so tests can feed canned archive bytes or network errors without hitting the network.HTTPDownloadersuccess / non-200 / network error paths viahttptest.Audio — split CGO playback into its own package
beep/otocode (Player,PlayMusicAndWait,PlaySound, embedded.mp3files) frominternal/audiointo a newinternal/audio/playbackpackage.internal/audionow only contains the pure-Go launchers (StartVibes,PlayNotification,NotificationSound) — importing it no longer pulls in ALSA.cmd/root.gowires the hidden_play-music/_play-soundsubcommands to the newplaybackpackage.libasoundisn't installed.Progress — new model tests
internal/progress/model_test.gocovering the ring buffer (addLine), theUpdatestate transitions (output line / done / timer / window size), the threeViewrender modes (running / success / failure / truncation), andlistenChchannel behavior.Prompt — extract pure helpers, test them
findDetectionByPM,truncateCmd, andscriptOptionLabelfrom the TTY-bound flows so they can be unit-tested without a PTY.SelectandSelectScriptnow delegate to those helpers; behavior is identical.Test plan
CGO_ENABLED=0 go test ./...— all greengo test ./internal/audio ./internal/progress ./internal/runner ./internal/prompt ./internal/updaterwith default CGO — all green (previously progress/runner failed to build)_play-musicand_play-soundstill work end-to-end after the audio package splitspm upgradestill downloads a release throughHTTPDownloader