mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
test: add mocks for RunnerInterface & Poller
This commit is contained in:
parent
82cbe791dc
commit
bfa86327ce
5 changed files with 104 additions and 1 deletions
52
internal/app/poll/mocks/Poller.go
Normal file
52
internal/app/poll/mocks/Poller.go
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Code generated by mockery v2.53.5. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// Poller is an autogenerated mock type for the Poller type
|
||||
type Poller struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Poll provides a mock function with no fields
|
||||
func (_m *Poller) Poll() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// Shutdown provides a mock function with given fields: ctx
|
||||
func (_m *Poller) Shutdown(ctx context.Context) error {
|
||||
ret := _m.Called(ctx)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Shutdown")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
|
||||
r0 = rf(ctx)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewPoller creates a new instance of Poller. 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 NewPoller(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
},
|
||||
) *Poller {
|
||||
mock := &Poller{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
const PollerID = "PollerID"
|
||||
|
||||
//go:generate mockery --name Poller
|
||||
type Poller interface {
|
||||
Poll()
|
||||
Shutdown(ctx context.Context) error
|
||||
|
|
49
internal/app/run/mocks/RunnerInterface.go
Normal file
49
internal/app/run/mocks/RunnerInterface.go
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Code generated by mockery v2.53.5. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
|
||||
runnerv1 "code.forgejo.org/forgejo/actions-proto/runner/v1"
|
||||
)
|
||||
|
||||
// RunnerInterface is an autogenerated mock type for the RunnerInterface type
|
||||
type RunnerInterface struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Run provides a mock function with given fields: ctx, task
|
||||
func (_m *RunnerInterface) Run(ctx context.Context, task *runnerv1.Task) error {
|
||||
ret := _m.Called(ctx, task)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Run")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, *runnerv1.Task) error); ok {
|
||||
r0 = rf(ctx, task)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewRunnerInterface creates a new instance of RunnerInterface. 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 NewRunnerInterface(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
},
|
||||
) *RunnerInterface {
|
||||
mock := &RunnerInterface{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
|
@ -48,6 +48,7 @@ type Runner struct {
|
|||
runningTasks sync.Map
|
||||
}
|
||||
|
||||
//go:generate mockery --name RunnerInterface
|
||||
type RunnerInterface interface {
|
||||
Run(ctx context.Context, task *runnerv1.Task) error
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.53.4. DO NOT EDIT.
|
||||
// Code generated by mockery v2.53.5. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue