Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/omni/update_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func TestUpdateCheckJSON(t *testing.T) {
UpdateAvailable: true,
CurrentVersion: "v1.2.0",
LatestVersion: "v1.3.0",
ReleaseURL: "https://example.test/v1.3.0",
ReleaseURL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0",
Upgrade: updatecheck.UpgradeInstructions{
Homebrew: "brew upgrade omni",
Homebrew: "brew update && brew upgrade omni",
Other: "install command",
},
}}
Expand Down
10 changes: 5 additions & 5 deletions cmd/omni/update_notice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ func TestAutomaticUpdateNotice(t *testing.T) {
result := updatecheck.Result{
UpdateAvailable: true,
LatestVersion: "v1.3.0",
ReleaseURL: "https://example.test/v1.3.0",
Upgrade: updatecheck.UpgradeInstructions{Homebrew: "brew upgrade omni", Other: "install command"},
ReleaseURL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0",
Upgrade: updatecheck.UpgradeInstructions{Homebrew: "brew update && brew upgrade omni", Other: "install command"},
}
ch := make(chan updateOutcome, 1)
ch <- updateOutcome{result: result}
Expand Down Expand Up @@ -282,15 +282,15 @@ func TestRecentHomebrewReleaseIsSuppressed(t *testing.T) {
}

func TestUpgradeHint(t *testing.T) {
unix := updatecheck.UpgradeInstructions{Homebrew: "brew upgrade omni", Other: "curl ... | sh"}
if got := upgradeHint(unix, true); got != "run: brew upgrade omni" {
unix := updatecheck.UpgradeInstructions{Homebrew: "brew update && brew upgrade omni", Other: "curl ... | sh"}
if got := upgradeHint(unix, true); got != "run: brew update && brew upgrade omni" {
t.Errorf("homebrew hint = %q", got)
}
if got := upgradeHint(unix, false); got != "run: curl ... | sh" {
t.Errorf("unix hint = %q", got)
}
// Windows has no Homebrew and no install.sh, so the advice is prose.
windows := updatecheck.UpgradeInstructions{Other: "download the latest release from https://example.test/latest"}
windows := updatecheck.UpgradeInstructions{Other: "download the latest release from https://github.com/exploreomni/cli/releases/latest"}
if got := upgradeHint(windows, false); got != windows.Other {
t.Errorf("windows hint = %q", got)
}
Expand Down
3 changes: 2 additions & 1 deletion internal/updatecheck/updatecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ func upgradeInstructions(goos string) UpgradeInstructions {
if goos == "windows" {
return UpgradeInstructions{Other: "download the latest release from " + releasesPage}
}
return UpgradeInstructions{Homebrew: "brew upgrade omni", Other: installCommand}
// brew upgrade only auto-refreshes taps every 24h, so it can miss a fresh release.
return UpgradeInstructions{Homebrew: "brew update && brew upgrade omni", Other: installCommand}
}

func (c *Checker) readState() (state, error) {
Expand Down
18 changes: 9 additions & 9 deletions internal/updatecheck/updatecheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func (c *clock) advance(d time.Duration) {
c.now = c.now.Add(d)
}

const releaseBody = `{"tag_name":"v1.3.0","html_url":"https://example.test/v1.3.0","published_at":"2026-08-30T12:00:00Z"}`
const releaseBody = `{"tag_name":"v1.3.0","html_url":"https://github.com/exploreomni/cli/releases/tag/v1.3.0","published_at":"2026-08-30T12:00:00Z"}`

func newTestChecker(t *testing.T, statePath string, clk *clock, rt roundTripFunc) *Checker {
t.Helper()
return &Checker{
Client: &http.Client{Transport: rt},
Endpoint: "https://example.test/latest",
Endpoint: defaultEndpoint,
StatePath: statePath,
Now: clk.Now,
}
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestAutomaticCheckFastPathDoesNotCreateTheLock(t *testing.T) {
t.Fatal("a throttled check must not make a request")
return nil, nil
})
wantRelease := Release{Version: "v1.3.0", URL: "https://example.test/v1.3.0"}
wantRelease := Release{Version: "v1.3.0", URL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0"}
if err := checker.writeState(state{
NextCheckAt: clk.Now().Add(checkInterval),
LatestRelease: wantRelease,
Expand Down Expand Up @@ -332,10 +332,10 @@ func TestStaleLeaseOwnerCannotOverwriteNewerState(t *testing.T) {
if !ok {
t.Fatal("expected the expired lease to be reclaimed")
}
checker.finishCheck(fresh, Release{Version: "v1.4.0", URL: "https://example.test/v1.4.0"}, nil)
checker.finishCheck(fresh, Release{Version: "v1.4.0", URL: "https://github.com/exploreomni/cli/releases/tag/v1.4.0"}, nil)

// The stale owner finally returns with an older answer.
checker.finishCheck(stale, Release{Version: "v1.3.0", URL: "https://example.test/v1.3.0"}, nil)
checker.finishCheck(stale, Release{Version: "v1.3.0", URL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0"}, nil)

s, err := checker.readState()
if err != nil {
Expand All @@ -352,7 +352,7 @@ func TestStaleLeaseOwnerCannotOverwriteNewerState(t *testing.T) {
func TestConcurrentNotificationClaimsProduceOneNotice(t *testing.T) {
clk := newClock()
statePath := filepath.Join(t.TempDir(), "update.json")
r := result("v1.2.0", Release{Version: "v1.3.0", URL: "https://example.test/release"})
r := result("v1.2.0", Release{Version: "v1.3.0", URL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0"})

var claims atomic.Int64
var wg sync.WaitGroup
Expand All @@ -376,7 +376,7 @@ func TestConcurrentNotificationClaimsProduceOneNotice(t *testing.T) {
func TestNotificationThrottle(t *testing.T) {
clk := newClock()
checker := newTestChecker(t, filepath.Join(t.TempDir(), "update.json"), clk, nil)
r := result("v1.2.0", Release{Version: "v1.3.0", URL: "https://example.test/release"})
r := result("v1.2.0", Release{Version: "v1.3.0", URL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0"})
if !checker.ClaimNotification(r) {
t.Fatal("a new release should be claimable before its first notification")
}
Expand All @@ -395,7 +395,7 @@ func TestNotificationThrottle(t *testing.T) {
func TestNotificationFastPathDoesNotCreateTheLock(t *testing.T) {
clk := newClock()
checker := newTestChecker(t, filepath.Join(t.TempDir(), "update.json"), clk, nil)
r := result("v1.2.0", Release{Version: "v1.3.0", URL: "https://example.test/release"})
r := result("v1.2.0", Release{Version: "v1.3.0", URL: "https://github.com/exploreomni/cli/releases/tag/v1.3.0"})
if err := checker.writeState(state{
NotifiedVersion: r.LatestVersion,
NotifiedAt: clk.Now(),
Expand Down Expand Up @@ -524,7 +524,7 @@ func TestUpgradeInstructionsArePlatformSpecific(t *testing.T) {
}
for _, goos := range []string{"darwin", "linux"} {
got := upgradeInstructions(goos)
if got.Homebrew != "brew upgrade omni" || got.Other != installCommand {
if got.Homebrew != "brew update && brew upgrade omni" || got.Other != installCommand {
t.Fatalf("%s instructions = %+v", goos, got)
}
}
Expand Down
Loading