utils_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 akeyless
  14. import (
  15. "testing"
  16. "github.com/stretchr/testify/require"
  17. esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  18. )
  19. func TestIgnoreCacheEnabled(t *testing.T) {
  20. t.Parallel()
  21. trueVal := true
  22. falseVal := false
  23. tests := []struct {
  24. name string
  25. prov *esv1.AkeylessProvider
  26. want bool
  27. }{
  28. {
  29. name: "nil provider",
  30. prov: nil,
  31. want: false,
  32. },
  33. {
  34. name: "unset",
  35. prov: &esv1.AkeylessProvider{},
  36. want: false,
  37. },
  38. {
  39. name: "explicit false",
  40. prov: &esv1.AkeylessProvider{IgnoreCache: &falseVal},
  41. want: false,
  42. },
  43. {
  44. name: "explicit true",
  45. prov: &esv1.AkeylessProvider{IgnoreCache: &trueVal},
  46. want: true,
  47. },
  48. }
  49. for _, tt := range tests {
  50. t.Run(tt.name, func(t *testing.T) {
  51. t.Parallel()
  52. require.Equal(t, tt.want, ignoreCacheEnabled(tt.prov))
  53. })
  54. }
  55. }