controlknobs_test.go 478 B

123456789101112131415161718192021
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package controlknobs
  4. import (
  5. "reflect"
  6. "testing"
  7. )
  8. func TestAsDebugJSON(t *testing.T) {
  9. var nilPtr *Knobs
  10. if got := nilPtr.AsDebugJSON(); got != nil {
  11. t.Errorf("AsDebugJSON(nil) = %v; want nil", got)
  12. }
  13. k := new(Knobs)
  14. got := k.AsDebugJSON()
  15. if want := reflect.TypeFor[Knobs]().NumField(); len(got) != want {
  16. t.Errorf("AsDebugJSON map has %d fields; want %v", len(got), want)
  17. }
  18. }