root_test.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 controller
  14. import (
  15. "testing"
  16. awsv2 "github.com/external-secrets/external-secrets/apis/provider/aws/v2alpha1"
  17. fakev2alpha1 "github.com/external-secrets/external-secrets/apis/provider/fake/v2alpha1"
  18. k8sv2alpha1 "github.com/external-secrets/external-secrets/apis/provider/kubernetes/v2alpha1"
  19. "k8s.io/apimachinery/pkg/runtime/schema"
  20. )
  21. func TestStoreRequeueIntervalDefault(t *testing.T) {
  22. flag := rootCmd.Flags().Lookup("store-requeue-interval")
  23. if flag == nil {
  24. t.Fatal("store-requeue-interval flag not found")
  25. }
  26. if flag.DefValue != "30s" {
  27. t.Fatalf("expected store-requeue-interval default 30s, got %q", flag.DefValue)
  28. }
  29. }
  30. func TestSchemeIncludesProviderV2Kinds(t *testing.T) {
  31. t.Helper()
  32. testCases := []struct {
  33. name string
  34. gvk schema.GroupVersionKind
  35. }{
  36. {
  37. name: "aws secretsmanager",
  38. gvk: awsv2.GroupVersion.WithKind(awsv2.SecretsManagerKind),
  39. },
  40. {
  41. name: "aws parameterstore",
  42. gvk: awsv2.GroupVersion.WithKind(awsv2.ParameterStoreKind),
  43. },
  44. {
  45. name: "fake",
  46. gvk: fakev2alpha1.GroupVersion.WithKind(fakev2alpha1.Kind),
  47. },
  48. {
  49. name: "kubernetes",
  50. gvk: k8sv2alpha1.GroupVersion.WithKind(k8sv2alpha1.Kind),
  51. },
  52. }
  53. for _, tc := range testCases {
  54. if _, err := scheme.New(tc.gvk); err != nil {
  55. t.Fatalf("%s kind not registered in controller scheme: %v", tc.name, err)
  56. }
  57. }
  58. }