provider_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 pulumi
  14. import (
  15. "errors"
  16. "testing"
  17. "github.com/stretchr/testify/assert"
  18. esv1 "github.com/external-secrets/external-secrets/apis/externalsecrets/v1"
  19. )
  20. func TestValidateStore(t *testing.T) {
  21. tests := map[string]struct {
  22. cfg esv1.PulumiProvider
  23. want error
  24. }{
  25. "invalid without organization": {
  26. cfg: esv1.PulumiProvider{
  27. Organization: "",
  28. Environment: "foo",
  29. },
  30. want: errors.New("organization is required"),
  31. },
  32. "invalid without environment": {
  33. cfg: esv1.PulumiProvider{
  34. Organization: "foo",
  35. Environment: "",
  36. },
  37. want: errors.New("environment is required"),
  38. },
  39. }
  40. for name, tc := range tests {
  41. t.Run(name, func(t *testing.T) {
  42. s := esv1.SecretStore{
  43. Spec: esv1.SecretStoreSpec{
  44. Provider: &esv1.SecretStoreProvider{
  45. Pulumi: &tc.cfg,
  46. },
  47. },
  48. }
  49. p := &Provider{}
  50. _, got := p.ValidateStore(&s)
  51. assert.Equal(t, tc.want, got)
  52. })
  53. }
  54. }