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:
12
pkg/kubelet/eviction/.mockery.yaml
Normal file
12
pkg/kubelet/eviction/.mockery.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
dir: .
|
||||
filename: "mock_{{.InterfaceName | snakecase}}_test.go"
|
||||
boilerplate-file: ../../../hack/boilerplate/boilerplate.generatego.txt
|
||||
inpackage: true
|
||||
with-expecter: true
|
||||
packages:
|
||||
k8s.io/kubernetes/pkg/kubelet/eviction:
|
||||
interfaces:
|
||||
CgroupNotifier:
|
||||
NotifierFactory:
|
||||
ThresholdNotifier:
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -2976,10 +2975,7 @@ func TestUpdateMemcgThreshold(t *testing.T) {
|
||||
}
|
||||
summaryProvider := &fakeSummaryProvider{result: makeMemoryStats("2Gi", map[*v1.Pod]statsapi.PodStats{})}
|
||||
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
thresholdNotifier := NewMockThresholdNotifier(mockCtrl)
|
||||
thresholdNotifier := NewMockThresholdNotifier(t)
|
||||
thresholdNotifier.EXPECT().UpdateThreshold(summaryProvider.result).Return(nil).Times(2)
|
||||
|
||||
manager := &managerImpl{
|
||||
@@ -3019,7 +3015,7 @@ func TestUpdateMemcgThreshold(t *testing.T) {
|
||||
}
|
||||
|
||||
// new memory threshold notifier that returns an error
|
||||
thresholdNotifier = NewMockThresholdNotifier(mockCtrl)
|
||||
thresholdNotifier = NewMockThresholdNotifier(t)
|
||||
thresholdNotifier.EXPECT().UpdateThreshold(summaryProvider.result).Return(fmt.Errorf("error updating threshold")).Times(1)
|
||||
thresholdNotifier.EXPECT().Description().Return("mock thresholdNotifier").Times(1)
|
||||
manager.thresholdNotifiers = []ThresholdNotifier{thresholdNotifier}
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
statsapi "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
|
||||
evictionapi "k8s.io/kubernetes/pkg/kubelet/eviction/api"
|
||||
@@ -130,18 +129,15 @@ func TestUpdateThreshold(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
notifierFactory := NewMockNotifierFactory(mockCtrl)
|
||||
notifier := NewMockCgroupNotifier(mockCtrl)
|
||||
notifierFactory := NewMockNotifierFactory(t)
|
||||
notifier := NewMockCgroupNotifier(t)
|
||||
|
||||
m := newTestMemoryThresholdNotifier(tc.evictionThreshold, notifierFactory, nil)
|
||||
notifierFactory.EXPECT().NewCgroupNotifier(testCgroupPath, memoryUsageAttribute, tc.expectedThreshold.Value()).Return(notifier, tc.updateThresholdErr).Times(1)
|
||||
var events chan<- struct{} = m.events
|
||||
notifier.EXPECT().Start(events).Return().AnyTimes()
|
||||
notifier.EXPECT().Start(events).Return().Maybe()
|
||||
err := m.UpdateThreshold(nodeSummary(tc.available, tc.workingSet, tc.usage, isAllocatableEvictionThreshold(tc.evictionThreshold)))
|
||||
if err != nil && !tc.expectErr {
|
||||
t.Errorf("Unexpected error updating threshold: %v", err)
|
||||
@@ -161,10 +157,8 @@ func TestStart(t *testing.T) {
|
||||
Quantity: &noResources,
|
||||
},
|
||||
}
|
||||
mockCtrl := gomock.NewController(t)
|
||||
defer mockCtrl.Finish()
|
||||
notifierFactory := NewMockNotifierFactory(mockCtrl)
|
||||
notifier := NewMockCgroupNotifier(mockCtrl)
|
||||
notifierFactory := NewMockNotifierFactory(t)
|
||||
notifier := NewMockCgroupNotifier(t)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(4)
|
||||
@@ -174,7 +168,7 @@ func TestStart(t *testing.T) {
|
||||
notifierFactory.EXPECT().NewCgroupNotifier(testCgroupPath, memoryUsageAttribute, int64(0)).Return(notifier, nil).Times(1)
|
||||
|
||||
var events chan<- struct{} = m.events
|
||||
notifier.EXPECT().Start(events).DoAndReturn(func(events chan<- struct{}) {
|
||||
notifier.EXPECT().Start(events).Run(func(events chan<- struct{}) {
|
||||
for i := 0; i < 4; i++ {
|
||||
events <- struct{}{}
|
||||
}
|
||||
|
||||
113
pkg/kubelet/eviction/mock_cgroup_notifier_test.go
Normal file
113
pkg/kubelet/eviction/mock_cgroup_notifier_test.go
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by mockery v2.40.3. DO NOT EDIT.
|
||||
|
||||
package eviction
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MockCgroupNotifier is an autogenerated mock type for the CgroupNotifier type
|
||||
type MockCgroupNotifier struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockCgroupNotifier_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockCgroupNotifier) EXPECT() *MockCgroupNotifier_Expecter {
|
||||
return &MockCgroupNotifier_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Start provides a mock function with given fields: eventCh
|
||||
func (_m *MockCgroupNotifier) Start(eventCh chan<- struct{}) {
|
||||
_m.Called(eventCh)
|
||||
}
|
||||
|
||||
// MockCgroupNotifier_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'
|
||||
type MockCgroupNotifier_Start_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Start is a helper method to define mock.On call
|
||||
// - eventCh chan<- struct{}
|
||||
func (_e *MockCgroupNotifier_Expecter) Start(eventCh interface{}) *MockCgroupNotifier_Start_Call {
|
||||
return &MockCgroupNotifier_Start_Call{Call: _e.mock.On("Start", eventCh)}
|
||||
}
|
||||
|
||||
func (_c *MockCgroupNotifier_Start_Call) Run(run func(eventCh chan<- struct{})) *MockCgroupNotifier_Start_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(chan<- struct{}))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCgroupNotifier_Start_Call) Return() *MockCgroupNotifier_Start_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCgroupNotifier_Start_Call) RunAndReturn(run func(chan<- struct{})) *MockCgroupNotifier_Start_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Stop provides a mock function with given fields:
|
||||
func (_m *MockCgroupNotifier) Stop() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// MockCgroupNotifier_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'
|
||||
type MockCgroupNotifier_Stop_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Stop is a helper method to define mock.On call
|
||||
func (_e *MockCgroupNotifier_Expecter) Stop() *MockCgroupNotifier_Stop_Call {
|
||||
return &MockCgroupNotifier_Stop_Call{Call: _e.mock.On("Stop")}
|
||||
}
|
||||
|
||||
func (_c *MockCgroupNotifier_Stop_Call) Run(run func()) *MockCgroupNotifier_Stop_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCgroupNotifier_Stop_Call) Return() *MockCgroupNotifier_Stop_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCgroupNotifier_Stop_Call) RunAndReturn(run func()) *MockCgroupNotifier_Stop_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockCgroupNotifier creates a new instance of MockCgroupNotifier. 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 NewMockCgroupNotifier(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockCgroupNotifier {
|
||||
mock := &MockCgroupNotifier{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
108
pkg/kubelet/eviction/mock_notifier_factory_test.go
Normal file
108
pkg/kubelet/eviction/mock_notifier_factory_test.go
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by mockery v2.40.3. DO NOT EDIT.
|
||||
|
||||
package eviction
|
||||
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MockNotifierFactory is an autogenerated mock type for the NotifierFactory type
|
||||
type MockNotifierFactory struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type MockNotifierFactory_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *MockNotifierFactory) EXPECT() *MockNotifierFactory_Expecter {
|
||||
return &MockNotifierFactory_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// NewCgroupNotifier provides a mock function with given fields: path, attribute, threshold
|
||||
func (_m *MockNotifierFactory) NewCgroupNotifier(path string, attribute string, threshold int64) (CgroupNotifier, error) {
|
||||
ret := _m.Called(path, attribute, threshold)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for NewCgroupNotifier")
|
||||
}
|
||||
|
||||
var r0 CgroupNotifier
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, int64) (CgroupNotifier, error)); ok {
|
||||
return rf(path, attribute, threshold)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string, int64) CgroupNotifier); ok {
|
||||
r0 = rf(path, attribute, threshold)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(CgroupNotifier)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string, int64) error); ok {
|
||||
r1 = rf(path, attribute, threshold)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MockNotifierFactory_NewCgroupNotifier_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewCgroupNotifier'
|
||||
type MockNotifierFactory_NewCgroupNotifier_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// NewCgroupNotifier is a helper method to define mock.On call
|
||||
// - path string
|
||||
// - attribute string
|
||||
// - threshold int64
|
||||
func (_e *MockNotifierFactory_Expecter) NewCgroupNotifier(path interface{}, attribute interface{}, threshold interface{}) *MockNotifierFactory_NewCgroupNotifier_Call {
|
||||
return &MockNotifierFactory_NewCgroupNotifier_Call{Call: _e.mock.On("NewCgroupNotifier", path, attribute, threshold)}
|
||||
}
|
||||
|
||||
func (_c *MockNotifierFactory_NewCgroupNotifier_Call) Run(run func(path string, attribute string, threshold int64)) *MockNotifierFactory_NewCgroupNotifier_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(string), args[2].(int64))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockNotifierFactory_NewCgroupNotifier_Call) Return(_a0 CgroupNotifier, _a1 error) *MockNotifierFactory_NewCgroupNotifier_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockNotifierFactory_NewCgroupNotifier_Call) RunAndReturn(run func(string, string, int64) (CgroupNotifier, error)) *MockNotifierFactory_NewCgroupNotifier_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockNotifierFactory creates a new instance of MockNotifierFactory. 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 NewMockNotifierFactory(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockNotifierFactory {
|
||||
mock := &MockNotifierFactory{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -14,373 +14,161 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: types.go
|
||||
//
|
||||
// Generated by this command:
|
||||
//
|
||||
// mockgen -source=types.go -destination=mock_threshold_notifier_test.go -package=eviction NotifierFactory,ThresholdNotifier
|
||||
//
|
||||
// Code generated by mockery v2.40.3. DO NOT EDIT.
|
||||
|
||||
// Package eviction is a generated GoMock package.
|
||||
package eviction
|
||||
|
||||
import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
time "time"
|
||||
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
v1alpha1 "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
|
||||
)
|
||||
|
||||
// MockManager is a mock of Manager interface.
|
||||
type MockManager struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockManagerMockRecorder
|
||||
}
|
||||
|
||||
// MockManagerMockRecorder is the mock recorder for MockManager.
|
||||
type MockManagerMockRecorder struct {
|
||||
mock *MockManager
|
||||
}
|
||||
|
||||
// NewMockManager creates a new mock instance.
|
||||
func NewMockManager(ctrl *gomock.Controller) *MockManager {
|
||||
mock := &MockManager{ctrl: ctrl}
|
||||
mock.recorder = &MockManagerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockManager) EXPECT() *MockManagerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// IsUnderDiskPressure mocks base method.
|
||||
func (m *MockManager) IsUnderDiskPressure() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsUnderDiskPressure")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsUnderDiskPressure indicates an expected call of IsUnderDiskPressure.
|
||||
func (mr *MockManagerMockRecorder) IsUnderDiskPressure() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnderDiskPressure", reflect.TypeOf((*MockManager)(nil).IsUnderDiskPressure))
|
||||
}
|
||||
|
||||
// IsUnderMemoryPressure mocks base method.
|
||||
func (m *MockManager) IsUnderMemoryPressure() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsUnderMemoryPressure")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsUnderMemoryPressure indicates an expected call of IsUnderMemoryPressure.
|
||||
func (mr *MockManagerMockRecorder) IsUnderMemoryPressure() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnderMemoryPressure", reflect.TypeOf((*MockManager)(nil).IsUnderMemoryPressure))
|
||||
}
|
||||
|
||||
// IsUnderPIDPressure mocks base method.
|
||||
func (m *MockManager) IsUnderPIDPressure() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsUnderPIDPressure")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsUnderPIDPressure indicates an expected call of IsUnderPIDPressure.
|
||||
func (mr *MockManagerMockRecorder) IsUnderPIDPressure() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsUnderPIDPressure", reflect.TypeOf((*MockManager)(nil).IsUnderPIDPressure))
|
||||
}
|
||||
|
||||
// Start mocks base method.
|
||||
func (m *MockManager) Start(diskInfoProvider DiskInfoProvider, podFunc ActivePodsFunc, podCleanedUpFunc PodCleanedUpFunc, monitoringInterval time.Duration) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Start", diskInfoProvider, podFunc, podCleanedUpFunc, monitoringInterval)
|
||||
}
|
||||
|
||||
// Start indicates an expected call of Start.
|
||||
func (mr *MockManagerMockRecorder) Start(diskInfoProvider, podFunc, podCleanedUpFunc, monitoringInterval any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockManager)(nil).Start), diskInfoProvider, podFunc, podCleanedUpFunc, monitoringInterval)
|
||||
}
|
||||
|
||||
// MockDiskInfoProvider is a mock of DiskInfoProvider interface.
|
||||
type MockDiskInfoProvider struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockDiskInfoProviderMockRecorder
|
||||
}
|
||||
|
||||
// MockDiskInfoProviderMockRecorder is the mock recorder for MockDiskInfoProvider.
|
||||
type MockDiskInfoProviderMockRecorder struct {
|
||||
mock *MockDiskInfoProvider
|
||||
}
|
||||
|
||||
// NewMockDiskInfoProvider creates a new mock instance.
|
||||
func NewMockDiskInfoProvider(ctrl *gomock.Controller) *MockDiskInfoProvider {
|
||||
mock := &MockDiskInfoProvider{ctrl: ctrl}
|
||||
mock.recorder = &MockDiskInfoProviderMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockDiskInfoProvider) EXPECT() *MockDiskInfoProviderMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// HasDedicatedImageFs mocks base method.
|
||||
func (m *MockDiskInfoProvider) HasDedicatedImageFs(ctx context.Context) (bool, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "HasDedicatedImageFs", ctx)
|
||||
ret0, _ := ret[0].(bool)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// HasDedicatedImageFs indicates an expected call of HasDedicatedImageFs.
|
||||
func (mr *MockDiskInfoProviderMockRecorder) HasDedicatedImageFs(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasDedicatedImageFs", reflect.TypeOf((*MockDiskInfoProvider)(nil).HasDedicatedImageFs), ctx)
|
||||
}
|
||||
|
||||
// MockImageGC is a mock of ImageGC interface.
|
||||
type MockImageGC struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockImageGCMockRecorder
|
||||
}
|
||||
|
||||
// MockImageGCMockRecorder is the mock recorder for MockImageGC.
|
||||
type MockImageGCMockRecorder struct {
|
||||
mock *MockImageGC
|
||||
}
|
||||
|
||||
// NewMockImageGC creates a new mock instance.
|
||||
func NewMockImageGC(ctrl *gomock.Controller) *MockImageGC {
|
||||
mock := &MockImageGC{ctrl: ctrl}
|
||||
mock.recorder = &MockImageGCMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockImageGC) EXPECT() *MockImageGCMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// DeleteUnusedImages mocks base method.
|
||||
func (m *MockImageGC) DeleteUnusedImages(ctx context.Context) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteUnusedImages", ctx)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteUnusedImages indicates an expected call of DeleteUnusedImages.
|
||||
func (mr *MockImageGCMockRecorder) DeleteUnusedImages(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteUnusedImages", reflect.TypeOf((*MockImageGC)(nil).DeleteUnusedImages), ctx)
|
||||
}
|
||||
|
||||
// MockContainerGC is a mock of ContainerGC interface.
|
||||
type MockContainerGC struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockContainerGCMockRecorder
|
||||
}
|
||||
|
||||
// MockContainerGCMockRecorder is the mock recorder for MockContainerGC.
|
||||
type MockContainerGCMockRecorder struct {
|
||||
mock *MockContainerGC
|
||||
}
|
||||
|
||||
// NewMockContainerGC creates a new mock instance.
|
||||
func NewMockContainerGC(ctrl *gomock.Controller) *MockContainerGC {
|
||||
mock := &MockContainerGC{ctrl: ctrl}
|
||||
mock.recorder = &MockContainerGCMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockContainerGC) EXPECT() *MockContainerGCMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// DeleteAllUnusedContainers mocks base method.
|
||||
func (m *MockContainerGC) DeleteAllUnusedContainers(ctx context.Context) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeleteAllUnusedContainers", ctx)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeleteAllUnusedContainers indicates an expected call of DeleteAllUnusedContainers.
|
||||
func (mr *MockContainerGCMockRecorder) DeleteAllUnusedContainers(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllUnusedContainers", reflect.TypeOf((*MockContainerGC)(nil).DeleteAllUnusedContainers), ctx)
|
||||
}
|
||||
|
||||
// IsContainerFsSeparateFromImageFs mocks base method.
|
||||
func (m *MockContainerGC) IsContainerFsSeparateFromImageFs(ctx context.Context) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsContainerFsSeparateFromImageFs", ctx)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsContainerFsSeparateFromImageFs indicates an expected call of IsContainerFsSeparateFromImageFs.
|
||||
func (mr *MockContainerGCMockRecorder) IsContainerFsSeparateFromImageFs(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsContainerFsSeparateFromImageFs", reflect.TypeOf((*MockContainerGC)(nil).IsContainerFsSeparateFromImageFs), ctx)
|
||||
}
|
||||
|
||||
// MockCgroupNotifier is a mock of CgroupNotifier interface.
|
||||
type MockCgroupNotifier struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockCgroupNotifierMockRecorder
|
||||
}
|
||||
|
||||
// MockCgroupNotifierMockRecorder is the mock recorder for MockCgroupNotifier.
|
||||
type MockCgroupNotifierMockRecorder struct {
|
||||
mock *MockCgroupNotifier
|
||||
}
|
||||
|
||||
// NewMockCgroupNotifier creates a new mock instance.
|
||||
func NewMockCgroupNotifier(ctrl *gomock.Controller) *MockCgroupNotifier {
|
||||
mock := &MockCgroupNotifier{ctrl: ctrl}
|
||||
mock.recorder = &MockCgroupNotifierMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockCgroupNotifier) EXPECT() *MockCgroupNotifierMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Start mocks base method.
|
||||
func (m *MockCgroupNotifier) Start(eventCh chan<- struct{}) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Start", eventCh)
|
||||
}
|
||||
|
||||
// Start indicates an expected call of Start.
|
||||
func (mr *MockCgroupNotifierMockRecorder) Start(eventCh any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockCgroupNotifier)(nil).Start), eventCh)
|
||||
}
|
||||
|
||||
// Stop mocks base method.
|
||||
func (m *MockCgroupNotifier) Stop() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Stop")
|
||||
}
|
||||
|
||||
// Stop indicates an expected call of Stop.
|
||||
func (mr *MockCgroupNotifierMockRecorder) Stop() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stop", reflect.TypeOf((*MockCgroupNotifier)(nil).Stop))
|
||||
}
|
||||
|
||||
// MockNotifierFactory is a mock of NotifierFactory interface.
|
||||
type MockNotifierFactory struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockNotifierFactoryMockRecorder
|
||||
}
|
||||
|
||||
// MockNotifierFactoryMockRecorder is the mock recorder for MockNotifierFactory.
|
||||
type MockNotifierFactoryMockRecorder struct {
|
||||
mock *MockNotifierFactory
|
||||
}
|
||||
|
||||
// NewMockNotifierFactory creates a new mock instance.
|
||||
func NewMockNotifierFactory(ctrl *gomock.Controller) *MockNotifierFactory {
|
||||
mock := &MockNotifierFactory{ctrl: ctrl}
|
||||
mock.recorder = &MockNotifierFactoryMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
||||
func (m *MockNotifierFactory) EXPECT() *MockNotifierFactoryMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// NewCgroupNotifier mocks base method.
|
||||
func (m *MockNotifierFactory) NewCgroupNotifier(path, attribute string, threshold int64) (CgroupNotifier, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NewCgroupNotifier", path, attribute, threshold)
|
||||
ret0, _ := ret[0].(CgroupNotifier)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// NewCgroupNotifier indicates an expected call of NewCgroupNotifier.
|
||||
func (mr *MockNotifierFactoryMockRecorder) NewCgroupNotifier(path, attribute, threshold any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewCgroupNotifier", reflect.TypeOf((*MockNotifierFactory)(nil).NewCgroupNotifier), path, attribute, threshold)
|
||||
}
|
||||
|
||||
// MockThresholdNotifier is a mock of ThresholdNotifier interface.
|
||||
// MockThresholdNotifier is an autogenerated mock type for the ThresholdNotifier type
|
||||
type MockThresholdNotifier struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockThresholdNotifierMockRecorder
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// MockThresholdNotifierMockRecorder is the mock recorder for MockThresholdNotifier.
|
||||
type MockThresholdNotifierMockRecorder struct {
|
||||
mock *MockThresholdNotifier
|
||||
type MockThresholdNotifier_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
// NewMockThresholdNotifier creates a new mock instance.
|
||||
func NewMockThresholdNotifier(ctrl *gomock.Controller) *MockThresholdNotifier {
|
||||
mock := &MockThresholdNotifier{ctrl: ctrl}
|
||||
mock.recorder = &MockThresholdNotifierMockRecorder{mock}
|
||||
func (_m *MockThresholdNotifier) EXPECT() *MockThresholdNotifier_Expecter {
|
||||
return &MockThresholdNotifier_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Description provides a mock function with given fields:
|
||||
func (_m *MockThresholdNotifier) Description() string {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Description")
|
||||
}
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func() string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockThresholdNotifier_Description_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Description'
|
||||
type MockThresholdNotifier_Description_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Description is a helper method to define mock.On call
|
||||
func (_e *MockThresholdNotifier_Expecter) Description() *MockThresholdNotifier_Description_Call {
|
||||
return &MockThresholdNotifier_Description_Call{Call: _e.mock.On("Description")}
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_Description_Call) Run(run func()) *MockThresholdNotifier_Description_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_Description_Call) Return(_a0 string) *MockThresholdNotifier_Description_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_Description_Call) RunAndReturn(run func() string) *MockThresholdNotifier_Description_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Start provides a mock function with given fields:
|
||||
func (_m *MockThresholdNotifier) Start() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// MockThresholdNotifier_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'
|
||||
type MockThresholdNotifier_Start_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Start is a helper method to define mock.On call
|
||||
func (_e *MockThresholdNotifier_Expecter) Start() *MockThresholdNotifier_Start_Call {
|
||||
return &MockThresholdNotifier_Start_Call{Call: _e.mock.On("Start")}
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_Start_Call) Run(run func()) *MockThresholdNotifier_Start_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_Start_Call) Return() *MockThresholdNotifier_Start_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_Start_Call) RunAndReturn(run func()) *MockThresholdNotifier_Start_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// UpdateThreshold provides a mock function with given fields: summary
|
||||
func (_m *MockThresholdNotifier) UpdateThreshold(summary *v1alpha1.Summary) error {
|
||||
ret := _m.Called(summary)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdateThreshold")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(*v1alpha1.Summary) error); ok {
|
||||
r0 = rf(summary)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockThresholdNotifier_UpdateThreshold_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateThreshold'
|
||||
type MockThresholdNotifier_UpdateThreshold_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// UpdateThreshold is a helper method to define mock.On call
|
||||
// - summary *v1alpha1.Summary
|
||||
func (_e *MockThresholdNotifier_Expecter) UpdateThreshold(summary interface{}) *MockThresholdNotifier_UpdateThreshold_Call {
|
||||
return &MockThresholdNotifier_UpdateThreshold_Call{Call: _e.mock.On("UpdateThreshold", summary)}
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_UpdateThreshold_Call) Run(run func(summary *v1alpha1.Summary)) *MockThresholdNotifier_UpdateThreshold_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(*v1alpha1.Summary))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_UpdateThreshold_Call) Return(_a0 error) *MockThresholdNotifier_UpdateThreshold_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockThresholdNotifier_UpdateThreshold_Call) RunAndReturn(run func(*v1alpha1.Summary) error) *MockThresholdNotifier_UpdateThreshold_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewMockThresholdNotifier creates a new instance of MockThresholdNotifier. 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 NewMockThresholdNotifier(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MockThresholdNotifier {
|
||||
mock := &MockThresholdNotifier{}
|
||||
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 *MockThresholdNotifier) EXPECT() *MockThresholdNotifierMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Description mocks base method.
|
||||
func (m *MockThresholdNotifier) Description() string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Description")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Description indicates an expected call of Description.
|
||||
func (mr *MockThresholdNotifierMockRecorder) Description() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Description", reflect.TypeOf((*MockThresholdNotifier)(nil).Description))
|
||||
}
|
||||
|
||||
// Start mocks base method.
|
||||
func (m *MockThresholdNotifier) Start() {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Start")
|
||||
}
|
||||
|
||||
// Start indicates an expected call of Start.
|
||||
func (mr *MockThresholdNotifierMockRecorder) Start() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockThresholdNotifier)(nil).Start))
|
||||
}
|
||||
|
||||
// UpdateThreshold mocks base method.
|
||||
func (m *MockThresholdNotifier) UpdateThreshold(summary *v1alpha1.Summary) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateThreshold", summary)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateThreshold indicates an expected call of UpdateThreshold.
|
||||
func (mr *MockThresholdNotifierMockRecorder) UpdateThreshold(summary any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateThreshold", reflect.TypeOf((*MockThresholdNotifier)(nil).UpdateThreshold), summary)
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
//go:generate mockgen -source=types.go -destination=mock_threshold_notifier_test.go -package=eviction NotifierFactory,ThresholdNotifier
|
||||
//go:generate mockery
|
||||
package eviction
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user