You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

  1. package common
  2. import (
  3. "testing"
  4. )
  5. func TestUserSourceConstants(t *testing.T) {
  6. if UserSourceLocal != "local" {
  7. t.Errorf("UserSourceLocal = %q, want %q", UserSourceLocal, "local")
  8. }
  9. if UserSourceSynced != "synced" {
  10. t.Errorf("UserSourceSynced = %q, want %q", UserSourceSynced, "synced")
  11. }
  12. }
  13. func TestIsSyncedUser(t *testing.T) {
  14. tests := []struct {
  15. name string
  16. source string
  17. want bool
  18. }{
  19. {"synced source", UserSourceSynced, true},
  20. {"local source", UserSourceLocal, false},
  21. {"empty source", "", false},
  22. }
  23. for _, tt := range tests {
  24. t.Run(tt.name, func(t *testing.T) {
  25. if got := IsSyncedUser(tt.source); got != tt.want {
  26. t.Errorf("IsSyncedUser(%q) = %v, want %v", tt.source, got, tt.want)
  27. }
  28. })
  29. }
  30. }
  31. func TestIsLocalUser(t *testing.T) {
  32. tests := []struct {
  33. name string
  34. source string
  35. want bool
  36. }{
  37. {"local source", UserSourceLocal, true},
  38. {"empty source", "", true},
  39. {"synced source", UserSourceSynced, false},
  40. }
  41. for _, tt := range tests {
  42. t.Run(tt.name, func(t *testing.T) {
  43. if got := IsLocalUser(tt.source); got != tt.want {
  44. t.Errorf("IsLocalUser(%q) = %v, want %v", tt.source, got, tt.want)
  45. }
  46. })
  47. }
  48. }