backend_test.go 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package ipn
  4. import (
  5. "testing"
  6. "tailscale.com/health"
  7. "tailscale.com/types/empty"
  8. )
  9. func TestNotifyString(t *testing.T) {
  10. for _, tt := range []struct {
  11. name string
  12. value Notify
  13. expected string
  14. }{
  15. {
  16. name: "notify-empty",
  17. value: Notify{},
  18. expected: "Notify{}",
  19. },
  20. {
  21. name: "notify-with-login-finished",
  22. value: Notify{LoginFinished: &empty.Message{}},
  23. expected: "Notify{LoginFinished}",
  24. },
  25. {
  26. name: "notify-with-multiple-fields",
  27. value: Notify{LoginFinished: &empty.Message{}, Health: &health.State{}},
  28. expected: "Notify{LoginFinished Health{...}}",
  29. },
  30. } {
  31. t.Run(tt.name, func(t *testing.T) {
  32. actual := tt.value.String()
  33. if actual != tt.expected {
  34. t.Fatalf("expected=%q, actual=%q", tt.expected, actual)
  35. }
  36. })
  37. }
  38. }