mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-02 01:51:59 +00:00
health,ipn/ipnlocal: hide update warning when auto-updates are enabled (#12631)
When auto-udpates are enabled, we don't need to nag users to update after a new release, before we release auto-updates. Updates https://github.com/tailscale/corp/issues/20081 Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
This commit is contained in:
@@ -9,6 +9,9 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"tailscale.com/tailcfg"
|
||||
"tailscale.com/types/opt"
|
||||
)
|
||||
|
||||
func TestAppendWarnableDebugFlags(t *testing.T) {
|
||||
@@ -214,3 +217,89 @@ func TestCheckDependsOnAppearsInUnhealthyState(t *testing.T) {
|
||||
t.Fatalf("Expected DependsOn = %v in the unhealthy state, got: %v", wantDependsOn, us2.DependsOn)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShowUpdateWarnable(t *testing.T) {
|
||||
tests := []struct {
|
||||
desc string
|
||||
check bool
|
||||
apply opt.Bool
|
||||
cv *tailcfg.ClientVersion
|
||||
wantWarnable *Warnable
|
||||
wantShow bool
|
||||
}{
|
||||
{
|
||||
desc: "nil CientVersion",
|
||||
check: true,
|
||||
cv: nil,
|
||||
wantWarnable: nil,
|
||||
wantShow: false,
|
||||
},
|
||||
{
|
||||
desc: "RunningLatest",
|
||||
check: true,
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: true},
|
||||
wantWarnable: nil,
|
||||
wantShow: false,
|
||||
},
|
||||
{
|
||||
desc: "no LatestVersion",
|
||||
check: true,
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: ""},
|
||||
wantWarnable: nil,
|
||||
wantShow: false,
|
||||
},
|
||||
{
|
||||
desc: "show regular update",
|
||||
check: true,
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3"},
|
||||
wantWarnable: updateAvailableWarnable,
|
||||
wantShow: true,
|
||||
},
|
||||
{
|
||||
desc: "show security update",
|
||||
check: true,
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3", UrgentSecurityUpdate: true},
|
||||
wantWarnable: securityUpdateAvailableWarnable,
|
||||
wantShow: true,
|
||||
},
|
||||
{
|
||||
desc: "update check disabled",
|
||||
check: false,
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3"},
|
||||
wantWarnable: nil,
|
||||
wantShow: false,
|
||||
},
|
||||
{
|
||||
desc: "hide update with auto-updates",
|
||||
check: true,
|
||||
apply: opt.NewBool(true),
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3"},
|
||||
wantWarnable: nil,
|
||||
wantShow: false,
|
||||
},
|
||||
{
|
||||
desc: "show security update with auto-updates",
|
||||
check: true,
|
||||
apply: opt.NewBool(true),
|
||||
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3", UrgentSecurityUpdate: true},
|
||||
wantWarnable: securityUpdateAvailableWarnable,
|
||||
wantShow: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.desc, func(t *testing.T) {
|
||||
tr := &Tracker{
|
||||
checkForUpdates: tt.check,
|
||||
applyUpdates: tt.apply,
|
||||
latestVersion: tt.cv,
|
||||
}
|
||||
gotWarnable, gotShow := tr.showUpdateWarnable()
|
||||
if gotWarnable != tt.wantWarnable {
|
||||
t.Errorf("got warnable: %v, want: %v", gotWarnable, tt.wantWarnable)
|
||||
}
|
||||
if gotShow != tt.wantShow {
|
||||
t.Errorf("got show: %v, want: %v", gotShow, tt.wantShow)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user