mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-30 05:25:35 +00:00
71029cea2d
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
50 lines
951 B
Go
50 lines
951 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package doctor
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"sync"
|
|
"testing"
|
|
|
|
qt "github.com/frankban/quicktest"
|
|
"tailscale.com/types/logger"
|
|
)
|
|
|
|
func TestRunChecks(t *testing.T) {
|
|
c := qt.New(t)
|
|
var (
|
|
mu sync.Mutex
|
|
lines []string
|
|
)
|
|
logf := func(format string, args ...any) {
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
lines = append(lines, fmt.Sprintf(format, args...))
|
|
}
|
|
|
|
ctx := context.Background()
|
|
RunChecks(ctx, logf,
|
|
testCheck1{},
|
|
CheckFunc("testcheck2", func(_ context.Context, log logger.Logf) error {
|
|
log("check 2")
|
|
return nil
|
|
}),
|
|
)
|
|
|
|
mu.Lock()
|
|
defer mu.Unlock()
|
|
c.Assert(lines, qt.Contains, "testcheck1: check 1")
|
|
c.Assert(lines, qt.Contains, "testcheck2: check 2")
|
|
}
|
|
|
|
type testCheck1 struct{}
|
|
|
|
func (t testCheck1) Name() string { return "testcheck1" }
|
|
func (t testCheck1) Run(_ context.Context, log logger.Logf) error {
|
|
log("check 1")
|
|
return nil
|
|
}
|