mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 13:05:46 +00:00
ebc552d2e0
This moves most of the health package global variables to a new `health.Tracker` type. But then rather than plumbing the Tracker in tsd.System everywhere, this only goes halfway and makes one new global Tracker (`health.Global`) that all the existing callers now use. A future change will eliminate that global. Updates #11874 Updates #4136 Change-Id: I6ee27e0b2e35f68cb38fecdb3b2dc4c3f2e09d68 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
34 lines
620 B
Go
34 lines
620 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package health
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func TestAppendWarnableDebugFlags(t *testing.T) {
|
|
var tr Tracker
|
|
|
|
for i := range 10 {
|
|
w := tr.NewWarnable(WithMapDebugFlag(fmt.Sprint(i)))
|
|
if i%2 == 0 {
|
|
w.Set(errors.New("boom"))
|
|
}
|
|
}
|
|
|
|
want := []string{"z", "y", "0", "2", "4", "6", "8"}
|
|
|
|
var got []string
|
|
for range 20 {
|
|
got = append(got[:0], "z", "y")
|
|
got = tr.AppendWarnableDebugFlags(got)
|
|
if !reflect.DeepEqual(got, want) {
|
|
t.Fatalf("AppendWarnableDebugFlags = %q; want %q", got, want)
|
|
}
|
|
}
|
|
}
|