From 9ef22f080250d9bd3c31987bbd7aeb80aff6021c Mon Sep 17 00:00:00 2001 From: devhaozi Date: Sun, 5 Jan 2025 07:55:14 +0000 Subject: [PATCH] chore: update mocks --- mocks/queue/Driver.go | 338 ++++++++++++++++++++++++++++++++++++++++++ mocks/queue/Queue.go | 123 +++++++++++---- mocks/queue/Task.go | 12 +- mocks/queue/Worker.go | 45 ++++++ 4 files changed, 486 insertions(+), 32 deletions(-) create mode 100644 mocks/queue/Driver.go diff --git a/mocks/queue/Driver.go b/mocks/queue/Driver.go new file mode 100644 index 000000000..e253b07f6 --- /dev/null +++ b/mocks/queue/Driver.go @@ -0,0 +1,338 @@ +// Code generated by mockery. DO NOT EDIT. + +package queue + +import ( + queue "github.com/goravel/framework/contracts/queue" + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// Driver is an autogenerated mock type for the Driver type +type Driver struct { + mock.Mock +} + +type Driver_Expecter struct { + mock *mock.Mock +} + +func (_m *Driver) EXPECT() *Driver_Expecter { + return &Driver_Expecter{mock: &_m.Mock} +} + +// Bulk provides a mock function with given fields: jobs, _a1 +func (_m *Driver) Bulk(jobs []queue.Jobs, _a1 string) error { + ret := _m.Called(jobs, _a1) + + if len(ret) == 0 { + panic("no return value specified for Bulk") + } + + var r0 error + if rf, ok := ret.Get(0).(func([]queue.Jobs, string) error); ok { + r0 = rf(jobs, _a1) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Driver_Bulk_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bulk' +type Driver_Bulk_Call struct { + *mock.Call +} + +// Bulk is a helper method to define mock.On call +// - jobs []queue.Jobs +// - _a1 string +func (_e *Driver_Expecter) Bulk(jobs interface{}, _a1 interface{}) *Driver_Bulk_Call { + return &Driver_Bulk_Call{Call: _e.mock.On("Bulk", jobs, _a1)} +} + +func (_c *Driver_Bulk_Call) Run(run func(jobs []queue.Jobs, _a1 string)) *Driver_Bulk_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]queue.Jobs), args[1].(string)) + }) + return _c +} + +func (_c *Driver_Bulk_Call) Return(_a0 error) *Driver_Bulk_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Driver_Bulk_Call) RunAndReturn(run func([]queue.Jobs, string) error) *Driver_Bulk_Call { + _c.Call.Return(run) + return _c +} + +// Connection provides a mock function with no fields +func (_m *Driver) Connection() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Connection") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Driver_Connection_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Connection' +type Driver_Connection_Call struct { + *mock.Call +} + +// Connection is a helper method to define mock.On call +func (_e *Driver_Expecter) Connection() *Driver_Connection_Call { + return &Driver_Connection_Call{Call: _e.mock.On("Connection")} +} + +func (_c *Driver_Connection_Call) Run(run func()) *Driver_Connection_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Driver_Connection_Call) Return(_a0 string) *Driver_Connection_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Driver_Connection_Call) RunAndReturn(run func() string) *Driver_Connection_Call { + _c.Call.Return(run) + return _c +} + +// Driver provides a mock function with no fields +func (_m *Driver) Driver() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Driver") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// Driver_Driver_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Driver' +type Driver_Driver_Call struct { + *mock.Call +} + +// Driver is a helper method to define mock.On call +func (_e *Driver_Expecter) Driver() *Driver_Driver_Call { + return &Driver_Driver_Call{Call: _e.mock.On("Driver")} +} + +func (_c *Driver_Driver_Call) Run(run func()) *Driver_Driver_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Driver_Driver_Call) Return(_a0 string) *Driver_Driver_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Driver_Driver_Call) RunAndReturn(run func() string) *Driver_Driver_Call { + _c.Call.Return(run) + return _c +} + +// Later provides a mock function with given fields: delay, job, args, _a3 +func (_m *Driver) Later(delay time.Duration, job queue.Job, args []interface{}, _a3 string) error { + ret := _m.Called(delay, job, args, _a3) + + if len(ret) == 0 { + panic("no return value specified for Later") + } + + var r0 error + if rf, ok := ret.Get(0).(func(time.Duration, queue.Job, []interface{}, string) error); ok { + r0 = rf(delay, job, args, _a3) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Driver_Later_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Later' +type Driver_Later_Call struct { + *mock.Call +} + +// Later is a helper method to define mock.On call +// - delay time.Duration +// - job queue.Job +// - args []interface{} +// - _a3 string +func (_e *Driver_Expecter) Later(delay interface{}, job interface{}, args interface{}, _a3 interface{}) *Driver_Later_Call { + return &Driver_Later_Call{Call: _e.mock.On("Later", delay, job, args, _a3)} +} + +func (_c *Driver_Later_Call) Run(run func(delay time.Duration, job queue.Job, args []interface{}, _a3 string)) *Driver_Later_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Duration), args[1].(queue.Job), args[2].([]interface{}), args[3].(string)) + }) + return _c +} + +func (_c *Driver_Later_Call) Return(_a0 error) *Driver_Later_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Driver_Later_Call) RunAndReturn(run func(time.Duration, queue.Job, []interface{}, string) error) *Driver_Later_Call { + _c.Call.Return(run) + return _c +} + +// Pop provides a mock function with given fields: _a0 +func (_m *Driver) Pop(_a0 string) (queue.Job, []interface{}, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for Pop") + } + + var r0 queue.Job + var r1 []interface{} + var r2 error + if rf, ok := ret.Get(0).(func(string) (queue.Job, []interface{}, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(string) queue.Job); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(queue.Job) + } + } + + if rf, ok := ret.Get(1).(func(string) []interface{}); ok { + r1 = rf(_a0) + } else { + if ret.Get(1) != nil { + r1 = ret.Get(1).([]interface{}) + } + } + + if rf, ok := ret.Get(2).(func(string) error); ok { + r2 = rf(_a0) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// Driver_Pop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Pop' +type Driver_Pop_Call struct { + *mock.Call +} + +// Pop is a helper method to define mock.On call +// - _a0 string +func (_e *Driver_Expecter) Pop(_a0 interface{}) *Driver_Pop_Call { + return &Driver_Pop_Call{Call: _e.mock.On("Pop", _a0)} +} + +func (_c *Driver_Pop_Call) Run(run func(_a0 string)) *Driver_Pop_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Driver_Pop_Call) Return(_a0 queue.Job, _a1 []interface{}, _a2 error) *Driver_Pop_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *Driver_Pop_Call) RunAndReturn(run func(string) (queue.Job, []interface{}, error)) *Driver_Pop_Call { + _c.Call.Return(run) + return _c +} + +// Push provides a mock function with given fields: job, args, _a2 +func (_m *Driver) Push(job queue.Job, args []interface{}, _a2 string) error { + ret := _m.Called(job, args, _a2) + + if len(ret) == 0 { + panic("no return value specified for Push") + } + + var r0 error + if rf, ok := ret.Get(0).(func(queue.Job, []interface{}, string) error); ok { + r0 = rf(job, args, _a2) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Driver_Push_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Push' +type Driver_Push_Call struct { + *mock.Call +} + +// Push is a helper method to define mock.On call +// - job queue.Job +// - args []interface{} +// - _a2 string +func (_e *Driver_Expecter) Push(job interface{}, args interface{}, _a2 interface{}) *Driver_Push_Call { + return &Driver_Push_Call{Call: _e.mock.On("Push", job, args, _a2)} +} + +func (_c *Driver_Push_Call) Run(run func(job queue.Job, args []interface{}, _a2 string)) *Driver_Push_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(queue.Job), args[1].([]interface{}), args[2].(string)) + }) + return _c +} + +func (_c *Driver_Push_Call) Return(_a0 error) *Driver_Push_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Driver_Push_Call) RunAndReturn(run func(queue.Job, []interface{}, string) error) *Driver_Push_Call { + _c.Call.Return(run) + return _c +} + +// NewDriver creates a new instance of Driver. 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 NewDriver(t interface { + mock.TestingT + Cleanup(func()) +}) *Driver { + mock := &Driver{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/mocks/queue/Queue.go b/mocks/queue/Queue.go index fc79dbcf3..7442fcf61 100644 --- a/mocks/queue/Queue.go +++ b/mocks/queue/Queue.go @@ -68,6 +68,64 @@ func (_c *Queue_Chain_Call) RunAndReturn(run func([]queue.Jobs) queue.Task) *Que return _c } +// GetJob provides a mock function with given fields: signature +func (_m *Queue) GetJob(signature string) (queue.Job, error) { + ret := _m.Called(signature) + + if len(ret) == 0 { + panic("no return value specified for GetJob") + } + + var r0 queue.Job + var r1 error + if rf, ok := ret.Get(0).(func(string) (queue.Job, error)); ok { + return rf(signature) + } + if rf, ok := ret.Get(0).(func(string) queue.Job); ok { + r0 = rf(signature) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(queue.Job) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(signature) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Queue_GetJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJob' +type Queue_GetJob_Call struct { + *mock.Call +} + +// GetJob is a helper method to define mock.On call +// - signature string +func (_e *Queue_Expecter) GetJob(signature interface{}) *Queue_GetJob_Call { + return &Queue_GetJob_Call{Call: _e.mock.On("GetJob", signature)} +} + +func (_c *Queue_GetJob_Call) Run(run func(signature string)) *Queue_GetJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Queue_GetJob_Call) Return(_a0 queue.Job, _a1 error) *Queue_GetJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Queue_GetJob_Call) RunAndReturn(run func(string) (queue.Job, error)) *Queue_GetJob_Call { + _c.Call.Return(run) + return _c +} + // GetJobs provides a mock function with no fields func (_m *Queue) GetJobs() []queue.Job { ret := _m.Called() @@ -116,7 +174,7 @@ func (_c *Queue_GetJobs_Call) RunAndReturn(run func() []queue.Job) *Queue_GetJob } // Job provides a mock function with given fields: job, args -func (_m *Queue) Job(job queue.Job, args []queue.Arg) queue.Task { +func (_m *Queue) Job(job queue.Job, args []interface{}) queue.Task { ret := _m.Called(job, args) if len(ret) == 0 { @@ -124,7 +182,7 @@ func (_m *Queue) Job(job queue.Job, args []queue.Arg) queue.Task { } var r0 queue.Task - if rf, ok := ret.Get(0).(func(queue.Job, []queue.Arg) queue.Task); ok { + if rf, ok := ret.Get(0).(func(queue.Job, []interface{}) queue.Task); ok { r0 = rf(job, args) } else { if ret.Get(0) != nil { @@ -142,14 +200,14 @@ type Queue_Job_Call struct { // Job is a helper method to define mock.On call // - job queue.Job -// - args []queue.Arg +// - args []interface{} func (_e *Queue_Expecter) Job(job interface{}, args interface{}) *Queue_Job_Call { return &Queue_Job_Call{Call: _e.mock.On("Job", job, args)} } -func (_c *Queue_Job_Call) Run(run func(job queue.Job, args []queue.Arg)) *Queue_Job_Call { +func (_c *Queue_Job_Call) Run(run func(job queue.Job, args []interface{})) *Queue_Job_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(queue.Job), args[1].([]queue.Arg)) + run(args[0].(queue.Job), args[1].([]interface{})) }) return _c } @@ -159,14 +217,27 @@ func (_c *Queue_Job_Call) Return(_a0 queue.Task) *Queue_Job_Call { return _c } -func (_c *Queue_Job_Call) RunAndReturn(run func(queue.Job, []queue.Arg) queue.Task) *Queue_Job_Call { +func (_c *Queue_Job_Call) RunAndReturn(run func(queue.Job, []interface{}) queue.Task) *Queue_Job_Call { _c.Call.Return(run) return _c } // Register provides a mock function with given fields: jobs -func (_m *Queue) Register(jobs []queue.Job) { - _m.Called(jobs) +func (_m *Queue) Register(jobs []queue.Job) error { + ret := _m.Called(jobs) + + if len(ret) == 0 { + panic("no return value specified for Register") + } + + var r0 error + if rf, ok := ret.Get(0).(func([]queue.Job) error); ok { + r0 = rf(jobs) + } else { + r0 = ret.Error(0) + } + + return r0 } // Queue_Register_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Register' @@ -187,21 +258,21 @@ func (_c *Queue_Register_Call) Run(run func(jobs []queue.Job)) *Queue_Register_C return _c } -func (_c *Queue_Register_Call) Return() *Queue_Register_Call { - _c.Call.Return() +func (_c *Queue_Register_Call) Return(_a0 error) *Queue_Register_Call { + _c.Call.Return(_a0) return _c } -func (_c *Queue_Register_Call) RunAndReturn(run func([]queue.Job)) *Queue_Register_Call { - _c.Run(run) +func (_c *Queue_Register_Call) RunAndReturn(run func([]queue.Job) error) *Queue_Register_Call { + _c.Call.Return(run) return _c } -// Worker provides a mock function with given fields: args -func (_m *Queue) Worker(args ...queue.Args) queue.Worker { - _va := make([]interface{}, len(args)) - for _i := range args { - _va[_i] = args[_i] +// Worker provides a mock function with given fields: payloads +func (_m *Queue) Worker(payloads ...*queue.Args) queue.Worker { + _va := make([]interface{}, len(payloads)) + for _i := range payloads { + _va[_i] = payloads[_i] } var _ca []interface{} _ca = append(_ca, _va...) @@ -212,8 +283,8 @@ func (_m *Queue) Worker(args ...queue.Args) queue.Worker { } var r0 queue.Worker - if rf, ok := ret.Get(0).(func(...queue.Args) queue.Worker); ok { - r0 = rf(args...) + if rf, ok := ret.Get(0).(func(...*queue.Args) queue.Worker); ok { + r0 = rf(payloads...) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(queue.Worker) @@ -229,18 +300,18 @@ type Queue_Worker_Call struct { } // Worker is a helper method to define mock.On call -// - args ...queue.Args -func (_e *Queue_Expecter) Worker(args ...interface{}) *Queue_Worker_Call { +// - payloads ...*queue.Args +func (_e *Queue_Expecter) Worker(payloads ...interface{}) *Queue_Worker_Call { return &Queue_Worker_Call{Call: _e.mock.On("Worker", - append([]interface{}{}, args...)...)} + append([]interface{}{}, payloads...)...)} } -func (_c *Queue_Worker_Call) Run(run func(args ...queue.Args)) *Queue_Worker_Call { +func (_c *Queue_Worker_Call) Run(run func(payloads ...*queue.Args)) *Queue_Worker_Call { _c.Call.Run(func(args mock.Arguments) { - variadicArgs := make([]queue.Args, len(args)-0) + variadicArgs := make([]*queue.Args, len(args)-0) for i, a := range args[0:] { if a != nil { - variadicArgs[i] = a.(queue.Args) + variadicArgs[i] = a.(*queue.Args) } } run(variadicArgs...) @@ -253,7 +324,7 @@ func (_c *Queue_Worker_Call) Return(_a0 queue.Worker) *Queue_Worker_Call { return _c } -func (_c *Queue_Worker_Call) RunAndReturn(run func(...queue.Args) queue.Worker) *Queue_Worker_Call { +func (_c *Queue_Worker_Call) RunAndReturn(run func(...*queue.Args) queue.Worker) *Queue_Worker_Call { _c.Call.Return(run) return _c } diff --git a/mocks/queue/Task.go b/mocks/queue/Task.go index 0e66c994d..6cf8a45aa 100644 --- a/mocks/queue/Task.go +++ b/mocks/queue/Task.go @@ -23,7 +23,7 @@ func (_m *Task) EXPECT() *Task_Expecter { } // Delay provides a mock function with given fields: _a0 -func (_m *Task) Delay(_a0 time.Time) queue.Task { +func (_m *Task) Delay(_a0 time.Duration) queue.Task { ret := _m.Called(_a0) if len(ret) == 0 { @@ -31,7 +31,7 @@ func (_m *Task) Delay(_a0 time.Time) queue.Task { } var r0 queue.Task - if rf, ok := ret.Get(0).(func(time.Time) queue.Task); ok { + if rf, ok := ret.Get(0).(func(time.Duration) queue.Task); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { @@ -48,14 +48,14 @@ type Task_Delay_Call struct { } // Delay is a helper method to define mock.On call -// - _a0 time.Time +// - _a0 time.Duration func (_e *Task_Expecter) Delay(_a0 interface{}) *Task_Delay_Call { return &Task_Delay_Call{Call: _e.mock.On("Delay", _a0)} } -func (_c *Task_Delay_Call) Run(run func(_a0 time.Time)) *Task_Delay_Call { +func (_c *Task_Delay_Call) Run(run func(_a0 time.Duration)) *Task_Delay_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(time.Time)) + run(args[0].(time.Duration)) }) return _c } @@ -65,7 +65,7 @@ func (_c *Task_Delay_Call) Return(_a0 queue.Task) *Task_Delay_Call { return _c } -func (_c *Task_Delay_Call) RunAndReturn(run func(time.Time) queue.Task) *Task_Delay_Call { +func (_c *Task_Delay_Call) RunAndReturn(run func(time.Duration) queue.Task) *Task_Delay_Call { _c.Call.Return(run) return _c } diff --git a/mocks/queue/Worker.go b/mocks/queue/Worker.go index d1e4b72d7..47d3dd775 100644 --- a/mocks/queue/Worker.go +++ b/mocks/queue/Worker.go @@ -62,6 +62,51 @@ func (_c *Worker_Run_Call) RunAndReturn(run func() error) *Worker_Run_Call { return _c } +// Shutdown provides a mock function with no fields +func (_m *Worker) Shutdown() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Shutdown") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Worker_Shutdown_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Shutdown' +type Worker_Shutdown_Call struct { + *mock.Call +} + +// Shutdown is a helper method to define mock.On call +func (_e *Worker_Expecter) Shutdown() *Worker_Shutdown_Call { + return &Worker_Shutdown_Call{Call: _e.mock.On("Shutdown")} +} + +func (_c *Worker_Shutdown_Call) Run(run func()) *Worker_Shutdown_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Worker_Shutdown_Call) Return(_a0 error) *Worker_Shutdown_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Worker_Shutdown_Call) RunAndReturn(run func() error) *Worker_Shutdown_Call { + _c.Call.Return(run) + return _c +} + // NewWorker creates a new instance of Worker. 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 NewWorker(t interface {