From e9378ea00e80db0ae1e77a4c55407a3156a2b954 Mon Sep 17 00:00:00 2001 From: MinerYang Date: Fri, 17 Jun 2022 18:19:23 +0800 Subject: [PATCH] clean up unused mock file&& regenerate mocks (#17025) clean up unused mock file&& re gen_mocks Signed-off-by: yminer --- .../jobservice/execution_controller.go | 84 ------------------ .../controller/jobservice/task_controller.go | 86 ------------------- .../controller/systemartifact/controller.go | 43 ++++++++++ 3 files changed, 43 insertions(+), 170 deletions(-) delete mode 100644 src/testing/controller/jobservice/execution_controller.go delete mode 100644 src/testing/controller/jobservice/task_controller.go create mode 100644 src/testing/controller/systemartifact/controller.go diff --git a/src/testing/controller/jobservice/execution_controller.go b/src/testing/controller/jobservice/execution_controller.go deleted file mode 100644 index b8dcec468..000000000 --- a/src/testing/controller/jobservice/execution_controller.go +++ /dev/null @@ -1,84 +0,0 @@ -// Code generated by mockery v2.1.0. DO NOT EDIT. - -package jobservice - -import ( - context "context" - - jobservice "github.com/goharbor/harbor/src/controller/jobservice" - mock "github.com/stretchr/testify/mock" - - q "github.com/goharbor/harbor/src/lib/q" -) - -// ExecutionController is an autogenerated mock type for the ExecutionController type -type ExecutionController struct { - mock.Mock -} - -// Count provides a mock function with given fields: ctx, vendorType, query -func (_m *ExecutionController) Count(ctx context.Context, vendorType string, query *q.Query) (int64, error) { - ret := _m.Called(ctx, vendorType, query) - - var r0 int64 - if rf, ok := ret.Get(0).(func(context.Context, string, *q.Query) int64); ok { - r0 = rf(ctx, vendorType, query) - } else { - r0 = ret.Get(0).(int64) - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, *q.Query) error); ok { - r1 = rf(ctx, vendorType, query) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Get provides a mock function with given fields: ctx, vendorType, executionID -func (_m *ExecutionController) Get(ctx context.Context, vendorType string, executionID int64) (*jobservice.Execution, error) { - ret := _m.Called(ctx, vendorType, executionID) - - var r0 *jobservice.Execution - if rf, ok := ret.Get(0).(func(context.Context, string, int64) *jobservice.Execution); ok { - r0 = rf(ctx, vendorType, executionID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*jobservice.Execution) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, int64) error); ok { - r1 = rf(ctx, vendorType, executionID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// List provides a mock function with given fields: ctx, vendorType, query -func (_m *ExecutionController) List(ctx context.Context, vendorType string, query *q.Query) ([]*jobservice.Execution, error) { - ret := _m.Called(ctx, vendorType, query) - - var r0 []*jobservice.Execution - if rf, ok := ret.Get(0).(func(context.Context, string, *q.Query) []*jobservice.Execution); ok { - r0 = rf(ctx, vendorType, query) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*jobservice.Execution) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, *q.Query) error); ok { - r1 = rf(ctx, vendorType, query) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/src/testing/controller/jobservice/task_controller.go b/src/testing/controller/jobservice/task_controller.go deleted file mode 100644 index 49e3d51cf..000000000 --- a/src/testing/controller/jobservice/task_controller.go +++ /dev/null @@ -1,86 +0,0 @@ -// Code generated by mockery v2.1.0. DO NOT EDIT. - -package jobservice - -import ( - context "context" - - jobservice "github.com/goharbor/harbor/src/controller/jobservice" - mock "github.com/stretchr/testify/mock" - - q "github.com/goharbor/harbor/src/lib/q" -) - -// TaskController is an autogenerated mock type for the TaskController type -type TaskController struct { - mock.Mock -} - -// Get provides a mock function with given fields: ctx, vendorType, id -func (_m *TaskController) Get(ctx context.Context, vendorType string, id int64) (*jobservice.Task, error) { - ret := _m.Called(ctx, vendorType, id) - - var r0 *jobservice.Task - if rf, ok := ret.Get(0).(func(context.Context, string, int64) *jobservice.Task); ok { - r0 = rf(ctx, vendorType, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*jobservice.Task) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, int64) error); ok { - r1 = rf(ctx, vendorType, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// GetLog provides a mock function with given fields: ctx, vendorType, id -func (_m *TaskController) GetLog(ctx context.Context, vendorType string, id int64) ([]byte, error) { - ret := _m.Called(ctx, vendorType, id) - - var r0 []byte - if rf, ok := ret.Get(0).(func(context.Context, string, int64) []byte); ok { - r0 = rf(ctx, vendorType, id) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]byte) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, int64) error); ok { - r1 = rf(ctx, vendorType, id) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// List provides a mock function with given fields: ctx, vendorType, query -func (_m *TaskController) List(ctx context.Context, vendorType string, query *q.Query) ([]*jobservice.Task, error) { - ret := _m.Called(ctx, vendorType, query) - - var r0 []*jobservice.Task - if rf, ok := ret.Get(0).(func(context.Context, string, *q.Query) []*jobservice.Task); ok { - r0 = rf(ctx, vendorType, query) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]*jobservice.Task) - } - } - - var r1 error - if rf, ok := ret.Get(1).(func(context.Context, string, *q.Query) error); ok { - r1 = rf(ctx, vendorType, query) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} diff --git a/src/testing/controller/systemartifact/controller.go b/src/testing/controller/systemartifact/controller.go new file mode 100644 index 000000000..39835f52e --- /dev/null +++ b/src/testing/controller/systemartifact/controller.go @@ -0,0 +1,43 @@ +// Code generated by mockery v2.12.3. DO NOT EDIT. + +package systemartifact + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// Controller is an autogenerated mock type for the Controller type +type Controller struct { + mock.Mock +} + +// Start provides a mock function with given fields: ctx, async, trigger +func (_m *Controller) Start(ctx context.Context, async bool, trigger string) error { + ret := _m.Called(ctx, async, trigger) + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, bool, string) error); ok { + r0 = rf(ctx, async, trigger) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +type NewControllerT interface { + mock.TestingT + Cleanup(func()) +} + +// NewController creates a new instance of Controller. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewController(t NewControllerT) *Controller { + mock := &Controller{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}