Skip to content

cmd: test update follow-up paths and clarify the dev rollback hint - #586

Merged
somanshreddy merged 1 commit into
mainfrom
11-16-update_test_followups
Nov 16, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
11-16-update_test_followups

Conversation

@somanshreddy

Copy link
Copy Markdown
Collaborator

Scope

Surfaces: CLI | Module: Self-update

Summary

Follow-up to #584 from review: tests for three heygen update paths that had none, and clearer recovery wording for dev builds when a failed update cannot restore the old binary. Live on the next release.

How it works

  • If replacing the binary fails and the old one cannot be restored, a dev build's error now says that install.sh installs the latest stable release, and where dev builds are published. Stable builds see the same message as before.
  • Tests now cover:
    • --version for a release that has no build for this platform reports "not found".
    • The background update check records "no release for this platform" as a successful check, not a failure that grows its backoff.
    • The reinstall hint is found under wrapped errors, and its stable and dev wording.

Testing

  • Each new test was checked by breaking the code it covers and watching it fail.
  • Not covered: that the dev updater passes the dev flag. It wraps go-selfupdate's concrete updater, which a test cannot fake without a real GitHub update.
  • make lint and the cmd/heygen tests pass.

🤖 Generated with Claude Code

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approving at 35b1e9958a.

The updateRollbackError seam is fine. It's an unexported package var. Production never reassigns it. The one test that swaps it restores it with t.Cleanup, and nothing in update_cdn_test.go or update_notice_test.go calls t.Parallel, so the swap can't leak into another test. Since go-selfupdate doesn't export the rollback error type, this is the smallest seam that works.

The untested true flag, read in code instead. newReleaseUpdater builds selfUpdater only when prerelease is true. cdnUpdater serves every other case, and its UpdateTo passes false. Both paths end in the same go-selfupdate/update.Apply (Updater.UpdateTo returns it directly), so RollbackError matches the GitHub path too. A dev build running update --version vX.Y.Z for a stable tag also goes through the GitHub updater, so it sees the dev wording. That's the right outcome: it's a dev build, and the hint tells it where both kinds of build live.

Each new test fails when the code it covers is broken (go test ./cmd/heygen/, Go 1.26, all green unmodified):

  • Dropping errors.Is(err, errNoPlatformEntry) from DetectVersion fails TestUpdate_VersionResolvesItsCDNFolder (the new "version lacks this platform" case).
  • Checking only the outer error instead of unwrapping fails TestWithRollbackHint.
  • Never adding the dev hint, and always adding it, each fail TestWithRollbackHint.
  • Counting ("", nil) as a failure fails TestUpdateCheckWorker_RecordsOutcome. So does keeping the previously cached Latest on ("", nil), so the test also pins that a platform with no build clears the cached latest.

The dev hint wording is accurate: install.sh only ever installs the stable release, and dev prereleases are published only as GitHub releases.

@somanshreddy
somanshreddy merged commit ac8d966 into main Nov 16, 2026
12 checks passed
@somanshreddy
somanshreddy deleted the 11-16-update_test_followups branch November 16, 2026 05:35
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