eso_chart_defaults_test.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. Copyright © The ESO Authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. https://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package addon
  14. import (
  15. "os"
  16. "path/filepath"
  17. "testing"
  18. "sigs.k8s.io/yaml"
  19. )
  20. func TestExternalSecretsChartDefaultsEnableV2StoreAPIs(t *testing.T) {
  21. path := filepath.Join("..", "..", "..", "deploy", "charts", "external-secrets", "values.yaml")
  22. data, err := os.ReadFile(path)
  23. if err != nil {
  24. t.Fatalf("read values.yaml: %v", err)
  25. }
  26. var values map[string]any
  27. if err := yaml.Unmarshal(data, &values); err != nil {
  28. t.Fatalf("unmarshal values.yaml: %v", err)
  29. }
  30. crds := requireMap(t, values, "crds")
  31. v2 := requireMap(t, values, "v2")
  32. requireBool(t, crds, "createClusterProviderClass", true)
  33. requireBool(t, crds, "createProviderStore", true)
  34. requireBool(t, crds, "createClusterProviderStore", true)
  35. requireBool(t, v2, "enabled", true)
  36. }
  37. func requireMap(t *testing.T, values map[string]any, key string) map[string]any {
  38. t.Helper()
  39. raw, ok := values[key]
  40. if !ok {
  41. t.Fatalf("missing %q", key)
  42. }
  43. out, ok := raw.(map[string]any)
  44. if !ok {
  45. t.Fatalf("%q is %T, want map[string]any", key, raw)
  46. }
  47. return out
  48. }
  49. func requireBool(t *testing.T, values map[string]any, key string, want bool) {
  50. t.Helper()
  51. raw, ok := values[key]
  52. if !ok {
  53. t.Fatalf("missing %q", key)
  54. }
  55. got, ok := raw.(bool)
  56. if !ok {
  57. t.Fatalf("%q is %T, want bool", key, raw)
  58. }
  59. if got != want {
  60. t.Fatalf("%q = %t, want %t", key, got, want)
  61. }
  62. }