mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-25 01:07:45 +00:00
Switch to stretchr/testify / mockery for mocks
testify is used throughout the codebase; this switches mocks from gomock to testify with the help of mockery for code generation. Handlers and mocks in test/utils/oidc are moved to a new package: mockery operates package by package, and requires packages to build correctly; test/utils/oidc/testserver.go relies on the mocks and fails to build when they are removed. Moving the interface and mocks to a different package allows mockery to process that package without having to build testserver.go. Signed-off-by: Stephen Kitt <skitt@redhat.com>
This commit is contained in:
@@ -14,112 +14,148 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: runtime_cache.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=runtime_cache.go -destination=testing/mock_runtime_cache.go -package=testing RuntimeCache
|
||||
//
|
||||
// Code generated by mockery v2.40.3. DO NOT EDIT.
|
||||
|
||||
// Package testing is a generated GoMock package.
|
||||
package testing
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
time "time"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
container "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
time "time"
|
||||
)
|
||||
|
||||
// MockRuntimeCache is a mock of RuntimeCache interface.
|
||||
// MockRuntimeCache is an autogenerated mock type for the RuntimeCache type
|
||||
type MockRuntimeCache struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockRuntimeCacheMockRecorder
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// MockRuntimeCacheMockRecorder is the mock recorder for MockRuntimeCache.
|
||||
type MockRuntimeCacheMockRecorder struct {
|
||||
mock *MockRuntimeCache
|
||||
type MockRuntimeCache_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
// NewMockRuntimeCache creates a new mock instance.
|
||||
func NewMockRuntimeCache(ctrl *gomock.Controller) *MockRuntimeCache {
|
||||
mock := &MockRuntimeCache{ctrl: ctrl}
|
||||
mock.recorder = &MockRuntimeCacheMockRecorder{mock}
|
||||
func (_m *MockRuntimeCache) EXPECT() *MockRuntimeCache_Expecter {
|
||||
return &MockRuntimeCache_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// ForceUpdateIfOlder provides a mock function with given fields: _a0, _a1
|
||||
func (_m *MockRuntimeCache) ForceUpdateIfOlder(_a0 context.Context, _a1 time.Time) error {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ForceUpdateIfOlder")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, time.Time) error); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockRuntimeCache_ForceUpdateIfOlder_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ForceUpdateIfOlder'
|
||||
type MockRuntimeCache_ForceUpdateIfOlder_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ForceUpdateIfOlder is a helper method to define mock.On call
|
||||
// - _a0 context.Context
|
||||
// - _a1 time.Time
|
||||
func (_e *MockRuntimeCache_Expecter) ForceUpdateIfOlder(_a0 interface{}, _a1 interface{}) *MockRuntimeCache_ForceUpdateIfOlder_Call {
|
||||
return &MockRuntimeCache_ForceUpdateIfOlder_Call{Call: _e.mock.On("ForceUpdateIfOlder", _a0, _a1)}
|
||||
}
|
||||
|
||||
func (_c *MockRuntimeCache_ForceUpdateIfOlder_Call) Run(run func(_a0 context.Context, _a1 time.Time)) *MockRuntimeCache_ForceUpdateIfOlder_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(time.Time))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRuntimeCache_ForceUpdateIfOlder_Call) Return(_a0 error) *MockRuntimeCache_ForceUpdateIfOlder_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRuntimeCache_ForceUpdateIfOlder_Call) RunAndReturn(run func(context.Context, time.Time) error) *MockRuntimeCache_ForceUpdateIfOlder_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetPods provides a mock function with given fields: _a0
|
||||
func (_m *MockRuntimeCache) GetPods(_a0 context.Context) ([]*container.Pod, error) {
|
||||
ret := _m.Called(_a0)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPods")
|
||||
}
|
||||
|
||||
var r0 []*container.Pod
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) ([]*container.Pod, error)); ok {
|
||||
return rf(_a0)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) []*container.Pod); ok {
|
||||
r0 = rf(_a0)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*container.Pod)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(_a0)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockRuntimeCache_GetPods_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPods'
|
||||
type MockRuntimeCache_GetPods_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetPods is a helper method to define mock.On call
|
||||
// - _a0 context.Context
|
||||
func (_e *MockRuntimeCache_Expecter) GetPods(_a0 interface{}) *MockRuntimeCache_GetPods_Call {
|
||||
return &MockRuntimeCache_GetPods_Call{Call: _e.mock.On("GetPods", _a0)}
|
||||
}
|
||||
|
||||
func (_c *MockRuntimeCache_GetPods_Call) Run(run func(_a0 context.Context)) *MockRuntimeCache_GetPods_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRuntimeCache_GetPods_Call) Return(_a0 []*container.Pod, _a1 error) *MockRuntimeCache_GetPods_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockRuntimeCache_GetPods_Call) RunAndReturn(run func(context.Context) ([]*container.Pod, error)) *MockRuntimeCache_GetPods_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockRuntimeCache creates a new instance of MockRuntimeCache. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMockRuntimeCache(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockRuntimeCache {
|
||||
mock := &MockRuntimeCache{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockRuntimeCache) EXPECT() *MockRuntimeCacheMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// ForceUpdateIfOlder mocks base method.
|
||||
func (m *MockRuntimeCache) ForceUpdateIfOlder(arg0 context.Context, arg1 time.Time) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ForceUpdateIfOlder", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ForceUpdateIfOlder indicates an expected call of ForceUpdateIfOlder.
|
||||
func (mr *MockRuntimeCacheMockRecorder) ForceUpdateIfOlder(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForceUpdateIfOlder", reflect.TypeOf((*MockRuntimeCache)(nil).ForceUpdateIfOlder), arg0, arg1)
|
||||
}
|
||||
|
||||
// GetPods mocks base method.
|
||||
func (m *MockRuntimeCache) GetPods(arg0 context.Context) ([]*container.Pod, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPods", arg0)
|
||||
ret0, _ := ret[0].([]*container.Pod)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetPods indicates an expected call of GetPods.
|
||||
func (mr *MockRuntimeCacheMockRecorder) GetPods(arg0 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPods", reflect.TypeOf((*MockRuntimeCache)(nil).GetPods), arg0)
|
||||
}
|
||||
|
||||
// MockpodsGetter is a mock of podsGetter interface.
|
||||
type MockpodsGetter struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockpodsGetterMockRecorder
|
||||
}
|
||||
|
||||
// MockpodsGetterMockRecorder is the mock recorder for MockpodsGetter.
|
||||
type MockpodsGetterMockRecorder struct {
|
||||
mock *MockpodsGetter
|
||||
}
|
||||
|
||||
// NewMockpodsGetter creates a new mock instance.
|
||||
func NewMockpodsGetter(ctrl *gomock.Controller) *MockpodsGetter {
|
||||
mock := &MockpodsGetter{ctrl: ctrl}
|
||||
mock.recorder = &MockpodsGetterMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockpodsGetter) EXPECT() *MockpodsGetterMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// GetPods mocks base method.
|
||||
func (m *MockpodsGetter) GetPods(arg0 context.Context, arg1 bool) ([]*container.Pod, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPods", arg0, arg1)
|
||||
ret0, _ := ret[0].([]*container.Pod)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetPods indicates an expected call of GetPods.
|
||||
func (mr *MockpodsGetterMockRecorder) GetPods(arg0, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPods", reflect.TypeOf((*MockpodsGetter)(nil).GetPods), arg0, arg1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user