compat_test.go 989 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package util
  2. import (
  3. "testing"
  4. )
  5. func TestGetArchType(t *testing.T) {
  6. type args struct {
  7. labels map[string]string
  8. }
  9. tests := map[string]struct {
  10. args args
  11. want string
  12. found bool
  13. }{
  14. "amd64 beta": {
  15. args: args{
  16. labels: map[string]string{
  17. "beta.kubernetes.io/arch": "amd64",
  18. },
  19. },
  20. want: "amd64",
  21. found: true,
  22. },
  23. "arm64 beta": {
  24. args: args{
  25. labels: map[string]string{
  26. "beta.kubernetes.io/arch": "arm64",
  27. },
  28. },
  29. want: "arm64",
  30. found: true,
  31. },
  32. "amd64": {
  33. args: args{
  34. labels: map[string]string{
  35. "kubernetes.io/arch": "amd64",
  36. },
  37. },
  38. want: "amd64",
  39. found: true,
  40. },
  41. }
  42. for name, tt := range tests {
  43. t.Run(name, func(t *testing.T) {
  44. got, found := GetArchType(tt.args.labels)
  45. if found != tt.found {
  46. t.Errorf("GetArchType() error = %v, wantErr %v", found, tt.found)
  47. return
  48. }
  49. if got != tt.want {
  50. t.Errorf("GetArchType() got = %v, want %v", got, tt.want)
  51. }
  52. })
  53. }
  54. }