mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-21 10:27:30 +00:00
hostinfo, control/controlclient: tell control when Ubuntu has disabled Tailscale's sources
Fixes #3177 Updates #2500 Change-Id: Iff2a8e27ec7d36a1c210263d6218f20ebed37924 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
d2ef73ed82
commit
3e1daab704
@@ -6,6 +6,7 @@ package hostinfo
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -27,3 +28,25 @@ func TestOSVersion(t *testing.T) {
|
||||
}
|
||||
t.Logf("Got: %#q", osVersion())
|
||||
}
|
||||
|
||||
func TestEtcAptSourceFileIsDisabled(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
in string
|
||||
want bool
|
||||
}{
|
||||
{"empty", "", false},
|
||||
{"normal", "deb foo\n", false},
|
||||
{"normal-commented", "# deb foo\n", false},
|
||||
{"normal-disabled-by-ubuntu", "# deb foo # disabled on upgrade to dingus\n", true},
|
||||
{"normal-disabled-then-uncommented", "deb foo # disabled on upgrade to dingus\n", false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := etcAptSourceFileIsDisabled(strings.NewReader(tt.in))
|
||||
if got != tt.want {
|
||||
t.Errorf("got %v; want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user