fake.go 1.6 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. gitlab "github.com/xanzy/go-gitlab"
  15. )
  16. type GitlabMockClient struct {
  17. getVariable func(pid interface{}, key string, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectVariable, *gitlab.Response, error)
  18. }
  19. func (mc *GitlabMockClient) GetVariable(pid interface{}, key string, opt *gitlab.GetProjectVariableOptions, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectVariable, *gitlab.Response, error) {
  20. return mc.getVariable(pid, key, nil)
  21. }
  22. func (mc *GitlabMockClient) WithValue(projectIDinput, keyInput string, output *gitlab.ProjectVariable, err error) {
  23. if mc != nil {
  24. mc.getVariable = func(pid interface{}, key string, options ...gitlab.RequestOptionFunc) (*gitlab.ProjectVariable, *gitlab.Response, error) {
  25. // type secretmanagerpb.AccessSecretVersionRequest contains unexported fields
  26. // use cmpopts.IgnoreUnexported to ignore all the unexported fields in the cmp.
  27. // if !cmp.Equal(paramReq, input, cmpopts.IgnoreUnexported(gitlab.ProjectVariable{})) {
  28. // return nil, nil, fmt.Errorf("unexpected test argument")
  29. // }
  30. return output, nil, err
  31. }
  32. }
  33. }