controlknobs_test.go 553 B

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