owner_test.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package kubemodel
  2. import (
  3. "testing"
  4. )
  5. func TestParseOwnerKind(t *testing.T) {
  6. tests := []struct {
  7. input string
  8. expected OwnerKind
  9. }{
  10. // Exact canonical values
  11. {"deployment", OwnerKindDeployment},
  12. {"statefulset", OwnerKindStatefulSet},
  13. {"daemonset", OwnerKindDaemonSet},
  14. {"job", OwnerKindJob},
  15. {"cronjob", OwnerKindCronJob},
  16. {"replicaset", OwnerKindReplicaSet},
  17. // Case-insensitive
  18. {"Deployment", OwnerKindDeployment},
  19. {"StatefulSet", OwnerKindStatefulSet},
  20. {"DaemonSet", OwnerKindDaemonSet},
  21. {"Job", OwnerKindJob},
  22. {"CronJob", OwnerKindCronJob},
  23. {"ReplicaSet", OwnerKindReplicaSet},
  24. {"DEPLOYMENT", OwnerKindDeployment},
  25. // Unknown input: lowercased passthrough (no mapping)
  26. {"Rollout", OwnerKind("rollout")},
  27. {"CustomController", OwnerKind("customcontroller")},
  28. {"", OwnerKind("")},
  29. }
  30. for _, tt := range tests {
  31. t.Run(tt.input, func(t *testing.T) {
  32. got := ParseOwnerKind(tt.input)
  33. if got != tt.expected {
  34. t.Errorf("ParseOwnerKind(%q) = %q, want %q", tt.input, got, tt.expected)
  35. }
  36. })
  37. }
  38. }