tailscale/control/controlknobs/controlknobs_test.go
Joe Tsai 94a4f701c2
all: use reflect.TypeFor now available in Go 1.22 (#11078)
Updates #cleanup

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2024-02-08 17:34:22 -08:00

22 lines
478 B
Go

// Copyright (c) Tailscale Inc & AUTHORS
// SPDX-License-Identifier: BSD-3-Clause
package controlknobs
import (
"reflect"
"testing"
)
func TestAsDebugJSON(t *testing.T) {
var nilPtr *Knobs
if got := nilPtr.AsDebugJSON(); got != nil {
t.Errorf("AsDebugJSON(nil) = %v; want nil", got)
}
k := new(Knobs)
got := k.AsDebugJSON()
if want := reflect.TypeFor[Knobs]().NumField(); len(got) != want {
t.Errorf("AsDebugJSON map has %d fields; want %v", len(got), want)
}
}