mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-09 01:34:39 +00:00
fixup! cmd/tailscale: get command for printing settings
TestGetDefaultSettings needs to start its own LocalBackend so it isn’t talking to a running tailscaled. Signed-off-by: Simon Law <sfllaw@sfllaw.ca>
This commit is contained in:
parent
25995745c9
commit
ebdf466f6d
@ -10,13 +10,10 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"tailscale.com/client/local"
|
"tailscale.com/client/local"
|
||||||
"tailscale.com/clientupdate"
|
|
||||||
"tailscale.com/ipn/ipnlocal"
|
"tailscale.com/ipn/ipnlocal"
|
||||||
"tailscale.com/ipn/ipnserver"
|
"tailscale.com/ipn/ipnserver"
|
||||||
"tailscale.com/ipn/store/mem"
|
"tailscale.com/ipn/store/mem"
|
||||||
@ -135,19 +132,27 @@ func TestGetDefaultSettings(t *testing.T) {
|
|||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
tstest.Replace[io.Writer](t, &Stdout, &stdout)
|
tstest.Replace[io.Writer](t, &Stdout, &stdout)
|
||||||
|
|
||||||
|
// Use a fake localClient that processes settings updates
|
||||||
|
lc := newLocalClient(t)
|
||||||
|
tstest.Replace(t, &localClient, lc)
|
||||||
|
|
||||||
if err := runGet(t.Context(), []string{f.Name}); err != nil {
|
if err := runGet(t.Context(), []string{f.Name}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var want string
|
want := f.DefValue
|
||||||
switch f.Name {
|
switch f.Name {
|
||||||
|
case "accept-routes":
|
||||||
|
// ipn.NewPrefs sets this to true
|
||||||
|
// but tailscale up sets it on start.
|
||||||
|
want = "true"
|
||||||
case "auto-update":
|
case "auto-update":
|
||||||
want = strconv.FormatBool(clientupdate.CanAutoUpdate())
|
// Unset by tailscale up.
|
||||||
case "operator":
|
want = "unset"
|
||||||
// applyImplicitPrefs will set the default operator to the current user
|
case "login-server":
|
||||||
want = os.Getenv("USER")
|
// The default settings is empty,
|
||||||
default:
|
// but tailscale up sets it on start.
|
||||||
want = f.DefValue
|
want = ""
|
||||||
}
|
}
|
||||||
want += "\n"
|
want += "\n"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user