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:
File diff suppressed because it is too large
Load Diff
@@ -14,74 +14,158 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: summary.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=summary.go -destination=testing/mock_summary_provider.go -package=testing SummaryProvider
|
||||
//
|
||||
// Code generated by mockery v2.40.3. DO NOT EDIT.
|
||||
|
||||
// Package testing is a generated GoMock package.
|
||||
package testing
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
v1alpha1 "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
|
||||
)
|
||||
|
||||
// MockSummaryProvider is a mock of SummaryProvider interface.
|
||||
// MockSummaryProvider is an autogenerated mock type for the SummaryProvider type
|
||||
type MockSummaryProvider struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockSummaryProviderMockRecorder
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// MockSummaryProviderMockRecorder is the mock recorder for MockSummaryProvider.
|
||||
type MockSummaryProviderMockRecorder struct {
|
||||
mock *MockSummaryProvider
|
||||
type MockSummaryProvider_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
// NewMockSummaryProvider creates a new mock instance.
|
||||
func NewMockSummaryProvider(ctrl *gomock.Controller) *MockSummaryProvider {
|
||||
mock := &MockSummaryProvider{ctrl: ctrl}
|
||||
mock.recorder = &MockSummaryProviderMockRecorder{mock}
|
||||
func (_m *MockSummaryProvider) EXPECT() *MockSummaryProvider_Expecter {
|
||||
return &MockSummaryProvider_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, updateStats
|
||||
func (_m *MockSummaryProvider) Get(ctx context.Context, updateStats bool) (*v1alpha1.Summary, error) {
|
||||
ret := _m.Called(ctx, updateStats)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 *v1alpha1.Summary
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, bool) (*v1alpha1.Summary, error)); ok {
|
||||
return rf(ctx, updateStats)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, bool) *v1alpha1.Summary); ok {
|
||||
r0 = rf(ctx, updateStats)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*v1alpha1.Summary)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context, bool) error); ok {
|
||||
r1 = rf(ctx, updateStats)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockSummaryProvider_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
|
||||
type MockSummaryProvider_Get_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Get is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - updateStats bool
|
||||
func (_e *MockSummaryProvider_Expecter) Get(ctx interface{}, updateStats interface{}) *MockSummaryProvider_Get_Call {
|
||||
return &MockSummaryProvider_Get_Call{Call: _e.mock.On("Get", ctx, updateStats)}
|
||||
}
|
||||
|
||||
func (_c *MockSummaryProvider_Get_Call) Run(run func(ctx context.Context, updateStats bool)) *MockSummaryProvider_Get_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context), args[1].(bool))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSummaryProvider_Get_Call) Return(_a0 *v1alpha1.Summary, _a1 error) *MockSummaryProvider_Get_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSummaryProvider_Get_Call) RunAndReturn(run func(context.Context, bool) (*v1alpha1.Summary, error)) *MockSummaryProvider_Get_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetCPUAndMemoryStats provides a mock function with given fields: ctx
|
||||
func (_m *MockSummaryProvider) GetCPUAndMemoryStats(ctx context.Context) (*v1alpha1.Summary, error) {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetCPUAndMemoryStats")
|
||||
}
|
||||
|
||||
var r0 *v1alpha1.Summary
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) (*v1alpha1.Summary, error)); ok {
|
||||
return rf(ctx)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context) *v1alpha1.Summary); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*v1alpha1.Summary)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(context.Context) error); ok {
|
||||
r1 = rf(ctx)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockSummaryProvider_GetCPUAndMemoryStats_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCPUAndMemoryStats'
|
||||
type MockSummaryProvider_GetCPUAndMemoryStats_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetCPUAndMemoryStats is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
func (_e *MockSummaryProvider_Expecter) GetCPUAndMemoryStats(ctx interface{}) *MockSummaryProvider_GetCPUAndMemoryStats_Call {
|
||||
return &MockSummaryProvider_GetCPUAndMemoryStats_Call{Call: _e.mock.On("GetCPUAndMemoryStats", ctx)}
|
||||
}
|
||||
|
||||
func (_c *MockSummaryProvider_GetCPUAndMemoryStats_Call) Run(run func(ctx context.Context)) *MockSummaryProvider_GetCPUAndMemoryStats_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(context.Context))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSummaryProvider_GetCPUAndMemoryStats_Call) Return(_a0 *v1alpha1.Summary, _a1 error) *MockSummaryProvider_GetCPUAndMemoryStats_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockSummaryProvider_GetCPUAndMemoryStats_Call) RunAndReturn(run func(context.Context) (*v1alpha1.Summary, error)) *MockSummaryProvider_GetCPUAndMemoryStats_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockSummaryProvider creates a new instance of MockSummaryProvider. 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 NewMockSummaryProvider(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockSummaryProvider {
|
||||
mock := &MockSummaryProvider{}
|
||||
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 *MockSummaryProvider) EXPECT() *MockSummaryProviderMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Get mocks base method.
|
||||
func (m *MockSummaryProvider) Get(ctx context.Context, updateStats bool) (*v1alpha1.Summary, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Get", ctx, updateStats)
|
||||
ret0, _ := ret[0].(*v1alpha1.Summary)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Get indicates an expected call of Get.
|
||||
func (mr *MockSummaryProviderMockRecorder) Get(ctx, updateStats any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockSummaryProvider)(nil).Get), ctx, updateStats)
|
||||
}
|
||||
|
||||
// GetCPUAndMemoryStats mocks base method.
|
||||
func (m *MockSummaryProvider) GetCPUAndMemoryStats(ctx context.Context) (*v1alpha1.Summary, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetCPUAndMemoryStats", ctx)
|
||||
ret0, _ := ret[0].(*v1alpha1.Summary)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetCPUAndMemoryStats indicates an expected call of GetCPUAndMemoryStats.
|
||||
func (mr *MockSummaryProviderMockRecorder) GetCPUAndMemoryStats(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCPUAndMemoryStats", reflect.TypeOf((*MockSummaryProvider)(nil).GetCPUAndMemoryStats), ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user