fake.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package fake
  13. import (
  14. "fmt"
  15. awssm "github.com/aws/aws-sdk-go/service/secretsmanager"
  16. "github.com/google/go-cmp/cmp"
  17. )
  18. // Client implements the aws secretsmanager interface.
  19. type Client struct {
  20. valFn func(*awssm.GetSecretValueInput) (*awssm.GetSecretValueOutput, error)
  21. }
  22. func (sm *Client) GetSecretValue(in *awssm.GetSecretValueInput) (*awssm.GetSecretValueOutput, error) {
  23. return sm.valFn(in)
  24. }
  25. func (sm *Client) WithValue(in *awssm.GetSecretValueInput, val *awssm.GetSecretValueOutput, err error) {
  26. sm.valFn = func(paramIn *awssm.GetSecretValueInput) (*awssm.GetSecretValueOutput, error) {
  27. if !cmp.Equal(paramIn, in) {
  28. return nil, fmt.Errorf("unexpected test argument")
  29. }
  30. return val, err
  31. }
  32. }