From 033f9b7226f5f4f5ed40887941b602e48fdfd700 Mon Sep 17 00:00:00 2001 From: Alexander Dammeier Date: Mon, 7 Oct 2024 13:13:24 +0200 Subject: [PATCH] #81 update mocks in main package with the current mockery config they will not be updated automatically with 'make mocks'. I needed to copy the interface into another package to generate the mocks. Then I could copy them on the right place. --- mock_controllerManager_test.go | 126 +++++++++++++++++++++++++++++++-- mock_eventRecorder_test.go | 11 ++- 2 files changed, 125 insertions(+), 12 deletions(-) diff --git a/mock_controllerManager_test.go b/mock_controllerManager_test.go index ae04a083..2cc3aa1b 100644 --- a/mock_controllerManager_test.go +++ b/mock_controllerManager_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.42.1. DO NOT EDIT. package main @@ -48,6 +48,10 @@ func (_m *mockControllerManager) EXPECT() *mockControllerManager_Expecter { func (_m *mockControllerManager) Add(_a0 manager.Runnable) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Add") + } + var r0 error if rf, ok := ret.Get(0).(func(manager.Runnable) error); ok { r0 = rf(_a0) @@ -90,6 +94,10 @@ func (_c *mockControllerManager_Add_Call) RunAndReturn(run func(manager.Runnable func (_m *mockControllerManager) AddHealthzCheck(name string, check healthz.Checker) error { ret := _m.Called(name, check) + if len(ret) == 0 { + panic("no return value specified for AddHealthzCheck") + } + var r0 error if rf, ok := ret.Get(0).(func(string, healthz.Checker) error); ok { r0 = rf(name, check) @@ -129,10 +137,61 @@ func (_c *mockControllerManager_AddHealthzCheck_Call) RunAndReturn(run func(stri return _c } +// AddMetricsServerExtraHandler provides a mock function with given fields: path, handler +func (_m *mockControllerManager) AddMetricsServerExtraHandler(path string, handler http.Handler) error { + ret := _m.Called(path, handler) + + if len(ret) == 0 { + panic("no return value specified for AddMetricsServerExtraHandler") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, http.Handler) error); ok { + r0 = rf(path, handler) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// mockControllerManager_AddMetricsServerExtraHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddMetricsServerExtraHandler' +type mockControllerManager_AddMetricsServerExtraHandler_Call struct { + *mock.Call +} + +// AddMetricsServerExtraHandler is a helper method to define mock.On call +// - path string +// - handler http.Handler +func (_e *mockControllerManager_Expecter) AddMetricsServerExtraHandler(path interface{}, handler interface{}) *mockControllerManager_AddMetricsServerExtraHandler_Call { + return &mockControllerManager_AddMetricsServerExtraHandler_Call{Call: _e.mock.On("AddMetricsServerExtraHandler", path, handler)} +} + +func (_c *mockControllerManager_AddMetricsServerExtraHandler_Call) Run(run func(path string, handler http.Handler)) *mockControllerManager_AddMetricsServerExtraHandler_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(http.Handler)) + }) + return _c +} + +func (_c *mockControllerManager_AddMetricsServerExtraHandler_Call) Return(_a0 error) *mockControllerManager_AddMetricsServerExtraHandler_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockControllerManager_AddMetricsServerExtraHandler_Call) RunAndReturn(run func(string, http.Handler) error) *mockControllerManager_AddMetricsServerExtraHandler_Call { + _c.Call.Return(run) + return _c +} + // AddReadyzCheck provides a mock function with given fields: name, check func (_m *mockControllerManager) AddReadyzCheck(name string, check healthz.Checker) error { ret := _m.Called(name, check) + if len(ret) == 0 { + panic("no return value specified for AddReadyzCheck") + } + var r0 error if rf, ok := ret.Get(0).(func(string, healthz.Checker) error); ok { r0 = rf(name, check) @@ -176,6 +235,10 @@ func (_c *mockControllerManager_AddReadyzCheck_Call) RunAndReturn(run func(strin func (_m *mockControllerManager) Elected() <-chan struct{} { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Elected") + } + var r0 <-chan struct{} if rf, ok := ret.Get(0).(func() <-chan struct{}); ok { r0 = rf() @@ -219,6 +282,10 @@ func (_c *mockControllerManager_Elected_Call) RunAndReturn(run func() <-chan str func (_m *mockControllerManager) GetAPIReader() client.Reader { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAPIReader") + } + var r0 client.Reader if rf, ok := ret.Get(0).(func() client.Reader); ok { r0 = rf() @@ -262,6 +329,10 @@ func (_c *mockControllerManager_GetAPIReader_Call) RunAndReturn(run func() clien func (_m *mockControllerManager) GetCache() cache.Cache { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetCache") + } + var r0 cache.Cache if rf, ok := ret.Get(0).(func() cache.Cache); ok { r0 = rf() @@ -305,6 +376,10 @@ func (_c *mockControllerManager_GetCache_Call) RunAndReturn(run func() cache.Cac func (_m *mockControllerManager) GetClient() client.Client { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetClient") + } + var r0 client.Client if rf, ok := ret.Get(0).(func() client.Client); ok { r0 = rf() @@ -348,6 +423,10 @@ func (_c *mockControllerManager_GetClient_Call) RunAndReturn(run func() client.C func (_m *mockControllerManager) GetConfig() *rest.Config { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetConfig") + } + var r0 *rest.Config if rf, ok := ret.Get(0).(func() *rest.Config); ok { r0 = rf() @@ -391,6 +470,10 @@ func (_c *mockControllerManager_GetConfig_Call) RunAndReturn(run func() *rest.Co func (_m *mockControllerManager) GetControllerOptions() config.Controller { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetControllerOptions") + } + var r0 config.Controller if rf, ok := ret.Get(0).(func() config.Controller); ok { r0 = rf() @@ -432,6 +515,10 @@ func (_c *mockControllerManager_GetControllerOptions_Call) RunAndReturn(run func func (_m *mockControllerManager) GetEventRecorderFor(name string) record.EventRecorder { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for GetEventRecorderFor") + } + var r0 record.EventRecorder if rf, ok := ret.Get(0).(func(string) record.EventRecorder); ok { r0 = rf(name) @@ -476,6 +563,10 @@ func (_c *mockControllerManager_GetEventRecorderFor_Call) RunAndReturn(run func( func (_m *mockControllerManager) GetFieldIndexer() client.FieldIndexer { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFieldIndexer") + } + var r0 client.FieldIndexer if rf, ok := ret.Get(0).(func() client.FieldIndexer); ok { r0 = rf() @@ -519,6 +610,10 @@ func (_c *mockControllerManager_GetFieldIndexer_Call) RunAndReturn(run func() cl func (_m *mockControllerManager) GetHTTPClient() *http.Client { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetHTTPClient") + } + var r0 *http.Client if rf, ok := ret.Get(0).(func() *http.Client); ok { r0 = rf() @@ -562,6 +657,10 @@ func (_c *mockControllerManager_GetHTTPClient_Call) RunAndReturn(run func() *htt func (_m *mockControllerManager) GetLogger() logr.Logger { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetLogger") + } + var r0 logr.Logger if rf, ok := ret.Get(0).(func() logr.Logger); ok { r0 = rf() @@ -603,6 +702,10 @@ func (_c *mockControllerManager_GetLogger_Call) RunAndReturn(run func() logr.Log func (_m *mockControllerManager) GetRESTMapper() meta.RESTMapper { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetRESTMapper") + } + var r0 meta.RESTMapper if rf, ok := ret.Get(0).(func() meta.RESTMapper); ok { r0 = rf() @@ -646,6 +749,10 @@ func (_c *mockControllerManager_GetRESTMapper_Call) RunAndReturn(run func() meta func (_m *mockControllerManager) GetScheme() *runtime.Scheme { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetScheme") + } + var r0 *runtime.Scheme if rf, ok := ret.Get(0).(func() *runtime.Scheme); ok { r0 = rf() @@ -689,6 +796,10 @@ func (_c *mockControllerManager_GetScheme_Call) RunAndReturn(run func() *runtime func (_m *mockControllerManager) GetWebhookServer() webhook.Server { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWebhookServer") + } + var r0 webhook.Server if rf, ok := ret.Get(0).(func() webhook.Server); ok { r0 = rf() @@ -732,6 +843,10 @@ func (_c *mockControllerManager_GetWebhookServer_Call) RunAndReturn(run func() w func (_m *mockControllerManager) Start(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -770,13 +885,12 @@ func (_c *mockControllerManager_Start_Call) RunAndReturn(run func(context.Contex return _c } -type mockConstructorTestingTnewMockControllerManager interface { +// newMockControllerManager creates a new instance of mockControllerManager. 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 newMockControllerManager(t interface { mock.TestingT Cleanup(func()) -} - -// newMockControllerManager creates a new instance of mockControllerManager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func newMockControllerManager(t mockConstructorTestingTnewMockControllerManager) *mockControllerManager { +}) *mockControllerManager { mock := &mockControllerManager{} mock.Mock.Test(t) diff --git a/mock_eventRecorder_test.go b/mock_eventRecorder_test.go index 326c8a9d..ece2c3e4 100644 --- a/mock_eventRecorder_test.go +++ b/mock_eventRecorder_test.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.42.1. DO NOT EDIT. package main @@ -151,13 +151,12 @@ func (_c *mockEventRecorder_Eventf_Call) RunAndReturn(run func(runtime.Object, s return _c } -type mockConstructorTestingTnewMockEventRecorder interface { +// newMockEventRecorder creates a new instance of mockEventRecorder. 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 newMockEventRecorder(t interface { mock.TestingT Cleanup(func()) -} - -// newMockEventRecorder creates a new instance of mockEventRecorder. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func newMockEventRecorder(t mockConstructorTestingTnewMockEventRecorder) *mockEventRecorder { +}) *mockEventRecorder { mock := &mockEventRecorder{} mock.Mock.Test(t)