Expand test coverage for run loop, updater, and helpers#9
Merged
Conversation
Raise main-package coverage from ~52% to ~83% by exercising the parts that were previously untested end to end: - run(): happy-path JSON run, SLO pass/violation exit codes, -json-out file (success + unwritable), -version, every flag-validation branch, missing profile, invalid proxy, and the -stats-addr server path. Driven through a helper that resets flag.CommandLine and captures stdout/stderr. - updater networking: getRelease (success/404/500/bad-JSON/empty-tag), fetchLatestRelease + fetchReleaseByTag endpoint paths, downloadTo, and downloadWithFallback (primary success, mirror fallback, all-fail). - runUpdate: -check (update available / up to date), pinned -version, API-error exit, -h, bad flag, and declining the confirmation prompt. - helpers: writeTempBinary read error, moveFile, color/TTY/NO_COLOR/dumb-term, statusColor ranges, and the plain status/net-error breakdowns. - cmd/testserver: hello + helloJSON handlers. To make the GitHub-backed paths testable without hitting the network, the hardcoded api.github.com / github.com hosts in update.go are now package vars (apiBaseURL/downloadBaseURL) that tests redirect at httptest servers; production behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Expands the test suite to cover the previously-untested core paths. Main-package statement coverage rises from ~52% → ~83% (
cmd/testserver0% → 50%;profileunchanged at ~82%).What's now tested
run()— the full load loop end to end via a helper that resetsflag.CommandLineand captures stdout/stderr:-json-outto a file (success + unwritable → exit 3)-version, every flag-validation branch (exit 2), missing profile / invalid proxy (exit 3), and the-stats-addrserver pathgetRelease(success/404/500/bad-JSON/empty-tag),fetchLatestRelease+fetchReleaseByTagendpoints,downloadTo, anddownloadWithFallback(primary success, mirror fallback, all-fail)runUpdate—-check(available / up to date), pinned-version, API error,-h, bad flag, and declining the confirmation prompt (viaos.Stdin)writeTempBinaryread error,moveFile, color /isTTY/NO_COLOR/TERM=dumb,statusColorranges, plain status & net-error breakdownscmd/testserver—hello+helloJSONhandlersProduction change
The hardcoded
api.github.com/github.qkg1.tophosts inupdate.goare now package vars (apiBaseURL/downloadBaseURL) so tests can point them athttptestservers. Production behavior is unchanged — they default to the real GitHub hosts.Verification
go vet,gofmt -l, andgo test -race ./...all clean.🤖 Generated with Claude Code