health: fix TestHealthMetric to pass on release branch

Fixes #14302

Change-Id: I9fd893a97711c72b713fe5535f2ccb93fadf7452
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick 2024-12-05 15:45:48 -08:00 committed by Brad Fitzpatrick
parent a482dc037b
commit dc6728729e

View File

@ -14,6 +14,7 @@
"tailscale.com/tailcfg" "tailscale.com/tailcfg"
"tailscale.com/types/opt" "tailscale.com/types/opt"
"tailscale.com/util/usermetric" "tailscale.com/util/usermetric"
"tailscale.com/version"
) )
func TestAppendWarnableDebugFlags(t *testing.T) { func TestAppendWarnableDebugFlags(t *testing.T) {
@ -352,6 +353,11 @@ func TestShowUpdateWarnable(t *testing.T) {
} }
func TestHealthMetric(t *testing.T) { func TestHealthMetric(t *testing.T) {
unstableBuildWarning := 0
if version.IsUnstableBuild() {
unstableBuildWarning = 1
}
tests := []struct { tests := []struct {
desc string desc string
check bool check bool
@ -361,20 +367,20 @@ func TestHealthMetric(t *testing.T) {
}{ }{
// When running in dev, and not initialising the client, there will be two warnings // When running in dev, and not initialising the client, there will be two warnings
// by default: // by default:
// - is-using-unstable-version // - is-using-unstable-version (except on the release branch)
// - wantrunning-false // - wantrunning-false
{ {
desc: "base-warnings", desc: "base-warnings",
check: true, check: true,
cv: nil, cv: nil,
wantMetricCount: 2, wantMetricCount: unstableBuildWarning + 1,
}, },
// with: update-available // with: update-available
{ {
desc: "update-warning", desc: "update-warning",
check: true, check: true,
cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3"}, cv: &tailcfg.ClientVersion{RunningLatest: false, LatestVersion: "1.2.3"},
wantMetricCount: 3, wantMetricCount: unstableBuildWarning + 2,
}, },
} }
for _, tt := range tests { for _, tt := range tests {