mock_cni.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. Copyright 2014 The Kubernetes 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. http://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. // mock_cni is a mock of the `libcni.CNI` interface. It's a handwritten mock
  14. // because there are only two functions to deal with.
  15. package mock_cni
  16. import (
  17. "github.com/containernetworking/cni/libcni"
  18. "github.com/containernetworking/cni/pkg/types"
  19. "github.com/stretchr/testify/mock"
  20. )
  21. type MockCNI struct {
  22. mock.Mock
  23. }
  24. func (m *MockCNI) AddNetwork(net *libcni.NetworkConfig, rt *libcni.RuntimeConf) (types.Result, error) {
  25. args := m.Called(net, rt)
  26. return args.Get(0).(types.Result), args.Error(1)
  27. }
  28. func (m *MockCNI) DelNetwork(net *libcni.NetworkConfig, rt *libcni.RuntimeConf) error {
  29. args := m.Called(net, rt)
  30. return args.Error(0)
  31. }
  32. func (m *MockCNI) DelNetworkList(net *libcni.NetworkConfigList, rt *libcni.RuntimeConf) error {
  33. args := m.Called(net, rt)
  34. return args.Error(0)
  35. }
  36. func (m *MockCNI) AddNetworkList(net *libcni.NetworkConfigList, rt *libcni.RuntimeConf) (types.Result, error) {
  37. args := m.Called(net, rt)
  38. return args.Get(0).(types.Result), args.Error(1)
  39. }