MCPcopy
hub / github.com/tailscale/tailscale / TestDebuggerKV

Function TestDebuggerKV

tsweb/debug_test.go:64–97  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62)
63
64func TestDebuggerKV(t *testing.T) {
65 mux := http.NewServeMux()
66 dbg := Debugger(mux)
67 dbg.KV("Donuts", 42)
68 dbg.KV("Secret code", "hunter2")
69 val := "red"
70 dbg.KVFunc("Condition", func() any { return val })
71
72 code, _ := get(mux, "/debug/", pubIP)
73 if code != 403 {
74 t.Fatalf("debug access wasn't denied, got %v", code)
75 }
76
77 code, body := get(mux, "/debug/", tsIP)
78 if code != 200 {
79 t.Fatalf("debug access failed, got %v", code)
80 }
81 for _, want := range []string{"Donuts", "42", "Secret code", "hunter2", "Condition", "red"} {
82 if !strings.Contains(body, want) {
83 t.Errorf("want %q in output, not found", want)
84 }
85 }
86
87 val = "green"
88 code, body = get(mux, "/debug/", tsIP)
89 if code != 200 {
90 t.Fatalf("debug access failed, got %v", code)
91 }
92 for _, want := range []string{"Condition", "green"} {
93 if !strings.Contains(body, want) {
94 t.Errorf("want %q in output, not found", want)
95 }
96 }
97}
98
99func TestDebuggerURL(t *testing.T) {
100 mux := http.NewServeMux()

Callers

nothing calls this directly

Calls 7

KVMethod · 0.80
KVFuncMethod · 0.80
DebuggerFunction · 0.70
getFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65
ContainsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…