1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2026-06-03 16:35:37 +02:00

Add backend interface to mockery to generated mock (#6269)

This commit is contained in:
6543
2026-03-20 16:56:51 +01:00
committed by GitHub
parent 09327abd03
commit db130b2a1c
2 changed files with 645 additions and 0 deletions
+1
View File
@@ -20,3 +20,4 @@ packages:
go.woodpecker-ci.org/woodpecker/v3/server/services/secret:
go.woodpecker-ci.org/woodpecker/v3/server/store:
go.woodpecker-ci.org/woodpecker/v3/woodpecker-go/woodpecker:
go.woodpecker-ci.org/woodpecker/v3/pipeline/backend/types:
@@ -0,0 +1,644 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package mocks
import (
"context"
"io"
mock "github.com/stretchr/testify/mock"
"github.com/urfave/cli/v3"
"go.woodpecker-ci.org/woodpecker/v3/pipeline/backend/types"
)
// NewMockBackend creates a new instance of MockBackend. 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 NewMockBackend(t interface {
mock.TestingT
Cleanup(func())
}) *MockBackend {
mock := &MockBackend{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockBackend is an autogenerated mock type for the Backend type
type MockBackend struct {
mock.Mock
}
type MockBackend_Expecter struct {
mock *mock.Mock
}
func (_m *MockBackend) EXPECT() *MockBackend_Expecter {
return &MockBackend_Expecter{mock: &_m.Mock}
}
// DestroyStep provides a mock function for the type MockBackend
func (_mock *MockBackend) DestroyStep(ctx context.Context, step *types.Step, taskUUID string) error {
ret := _mock.Called(ctx, step, taskUUID)
if len(ret) == 0 {
panic("no return value specified for DestroyStep")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Step, string) error); ok {
r0 = returnFunc(ctx, step, taskUUID)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockBackend_DestroyStep_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestroyStep'
type MockBackend_DestroyStep_Call struct {
*mock.Call
}
// DestroyStep is a helper method to define mock.On call
// - ctx context.Context
// - step *types.Step
// - taskUUID string
func (_e *MockBackend_Expecter) DestroyStep(ctx interface{}, step interface{}, taskUUID interface{}) *MockBackend_DestroyStep_Call {
return &MockBackend_DestroyStep_Call{Call: _e.mock.On("DestroyStep", ctx, step, taskUUID)}
}
func (_c *MockBackend_DestroyStep_Call) Run(run func(ctx context.Context, step *types.Step, taskUUID string)) *MockBackend_DestroyStep_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 *types.Step
if args[1] != nil {
arg1 = args[1].(*types.Step)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockBackend_DestroyStep_Call) Return(err error) *MockBackend_DestroyStep_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockBackend_DestroyStep_Call) RunAndReturn(run func(ctx context.Context, step *types.Step, taskUUID string) error) *MockBackend_DestroyStep_Call {
_c.Call.Return(run)
return _c
}
// DestroyWorkflow provides a mock function for the type MockBackend
func (_mock *MockBackend) DestroyWorkflow(ctx context.Context, conf *types.Config, taskUUID string) error {
ret := _mock.Called(ctx, conf, taskUUID)
if len(ret) == 0 {
panic("no return value specified for DestroyWorkflow")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Config, string) error); ok {
r0 = returnFunc(ctx, conf, taskUUID)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockBackend_DestroyWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DestroyWorkflow'
type MockBackend_DestroyWorkflow_Call struct {
*mock.Call
}
// DestroyWorkflow is a helper method to define mock.On call
// - ctx context.Context
// - conf *types.Config
// - taskUUID string
func (_e *MockBackend_Expecter) DestroyWorkflow(ctx interface{}, conf interface{}, taskUUID interface{}) *MockBackend_DestroyWorkflow_Call {
return &MockBackend_DestroyWorkflow_Call{Call: _e.mock.On("DestroyWorkflow", ctx, conf, taskUUID)}
}
func (_c *MockBackend_DestroyWorkflow_Call) Run(run func(ctx context.Context, conf *types.Config, taskUUID string)) *MockBackend_DestroyWorkflow_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 *types.Config
if args[1] != nil {
arg1 = args[1].(*types.Config)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockBackend_DestroyWorkflow_Call) Return(err error) *MockBackend_DestroyWorkflow_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockBackend_DestroyWorkflow_Call) RunAndReturn(run func(ctx context.Context, conf *types.Config, taskUUID string) error) *MockBackend_DestroyWorkflow_Call {
_c.Call.Return(run)
return _c
}
// Flags provides a mock function for the type MockBackend
func (_mock *MockBackend) Flags() []cli.Flag {
ret := _mock.Called()
if len(ret) == 0 {
panic("no return value specified for Flags")
}
var r0 []cli.Flag
if returnFunc, ok := ret.Get(0).(func() []cli.Flag); ok {
r0 = returnFunc()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]cli.Flag)
}
}
return r0
}
// MockBackend_Flags_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Flags'
type MockBackend_Flags_Call struct {
*mock.Call
}
// Flags is a helper method to define mock.On call
func (_e *MockBackend_Expecter) Flags() *MockBackend_Flags_Call {
return &MockBackend_Flags_Call{Call: _e.mock.On("Flags")}
}
func (_c *MockBackend_Flags_Call) Run(run func()) *MockBackend_Flags_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockBackend_Flags_Call) Return(flags []cli.Flag) *MockBackend_Flags_Call {
_c.Call.Return(flags)
return _c
}
func (_c *MockBackend_Flags_Call) RunAndReturn(run func() []cli.Flag) *MockBackend_Flags_Call {
_c.Call.Return(run)
return _c
}
// IsAvailable provides a mock function for the type MockBackend
func (_mock *MockBackend) IsAvailable(ctx context.Context) bool {
ret := _mock.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for IsAvailable")
}
var r0 bool
if returnFunc, ok := ret.Get(0).(func(context.Context) bool); ok {
r0 = returnFunc(ctx)
} else {
r0 = ret.Get(0).(bool)
}
return r0
}
// MockBackend_IsAvailable_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsAvailable'
type MockBackend_IsAvailable_Call struct {
*mock.Call
}
// IsAvailable is a helper method to define mock.On call
// - ctx context.Context
func (_e *MockBackend_Expecter) IsAvailable(ctx interface{}) *MockBackend_IsAvailable_Call {
return &MockBackend_IsAvailable_Call{Call: _e.mock.On("IsAvailable", ctx)}
}
func (_c *MockBackend_IsAvailable_Call) Run(run func(ctx context.Context)) *MockBackend_IsAvailable_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
run(
arg0,
)
})
return _c
}
func (_c *MockBackend_IsAvailable_Call) Return(b bool) *MockBackend_IsAvailable_Call {
_c.Call.Return(b)
return _c
}
func (_c *MockBackend_IsAvailable_Call) RunAndReturn(run func(ctx context.Context) bool) *MockBackend_IsAvailable_Call {
_c.Call.Return(run)
return _c
}
// Load provides a mock function for the type MockBackend
func (_mock *MockBackend) Load(ctx context.Context) (*types.BackendInfo, error) {
ret := _mock.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Load")
}
var r0 *types.BackendInfo
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context) (*types.BackendInfo, error)); ok {
return returnFunc(ctx)
}
if returnFunc, ok := ret.Get(0).(func(context.Context) *types.BackendInfo); ok {
r0 = returnFunc(ctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.BackendInfo)
}
}
if returnFunc, ok := ret.Get(1).(func(context.Context) error); ok {
r1 = returnFunc(ctx)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockBackend_Load_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Load'
type MockBackend_Load_Call struct {
*mock.Call
}
// Load is a helper method to define mock.On call
// - ctx context.Context
func (_e *MockBackend_Expecter) Load(ctx interface{}) *MockBackend_Load_Call {
return &MockBackend_Load_Call{Call: _e.mock.On("Load", ctx)}
}
func (_c *MockBackend_Load_Call) Run(run func(ctx context.Context)) *MockBackend_Load_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
run(
arg0,
)
})
return _c
}
func (_c *MockBackend_Load_Call) Return(backendInfo *types.BackendInfo, err error) *MockBackend_Load_Call {
_c.Call.Return(backendInfo, err)
return _c
}
func (_c *MockBackend_Load_Call) RunAndReturn(run func(ctx context.Context) (*types.BackendInfo, error)) *MockBackend_Load_Call {
_c.Call.Return(run)
return _c
}
// Name provides a mock function for the type MockBackend
func (_mock *MockBackend) Name() string {
ret := _mock.Called()
if len(ret) == 0 {
panic("no return value specified for Name")
}
var r0 string
if returnFunc, ok := ret.Get(0).(func() string); ok {
r0 = returnFunc()
} else {
r0 = ret.Get(0).(string)
}
return r0
}
// MockBackend_Name_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Name'
type MockBackend_Name_Call struct {
*mock.Call
}
// Name is a helper method to define mock.On call
func (_e *MockBackend_Expecter) Name() *MockBackend_Name_Call {
return &MockBackend_Name_Call{Call: _e.mock.On("Name")}
}
func (_c *MockBackend_Name_Call) Run(run func()) *MockBackend_Name_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockBackend_Name_Call) Return(s string) *MockBackend_Name_Call {
_c.Call.Return(s)
return _c
}
func (_c *MockBackend_Name_Call) RunAndReturn(run func() string) *MockBackend_Name_Call {
_c.Call.Return(run)
return _c
}
// SetupWorkflow provides a mock function for the type MockBackend
func (_mock *MockBackend) SetupWorkflow(ctx context.Context, conf *types.Config, taskUUID string) error {
ret := _mock.Called(ctx, conf, taskUUID)
if len(ret) == 0 {
panic("no return value specified for SetupWorkflow")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Config, string) error); ok {
r0 = returnFunc(ctx, conf, taskUUID)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockBackend_SetupWorkflow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetupWorkflow'
type MockBackend_SetupWorkflow_Call struct {
*mock.Call
}
// SetupWorkflow is a helper method to define mock.On call
// - ctx context.Context
// - conf *types.Config
// - taskUUID string
func (_e *MockBackend_Expecter) SetupWorkflow(ctx interface{}, conf interface{}, taskUUID interface{}) *MockBackend_SetupWorkflow_Call {
return &MockBackend_SetupWorkflow_Call{Call: _e.mock.On("SetupWorkflow", ctx, conf, taskUUID)}
}
func (_c *MockBackend_SetupWorkflow_Call) Run(run func(ctx context.Context, conf *types.Config, taskUUID string)) *MockBackend_SetupWorkflow_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 *types.Config
if args[1] != nil {
arg1 = args[1].(*types.Config)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockBackend_SetupWorkflow_Call) Return(err error) *MockBackend_SetupWorkflow_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockBackend_SetupWorkflow_Call) RunAndReturn(run func(ctx context.Context, conf *types.Config, taskUUID string) error) *MockBackend_SetupWorkflow_Call {
_c.Call.Return(run)
return _c
}
// StartStep provides a mock function for the type MockBackend
func (_mock *MockBackend) StartStep(ctx context.Context, step *types.Step, taskUUID string) error {
ret := _mock.Called(ctx, step, taskUUID)
if len(ret) == 0 {
panic("no return value specified for StartStep")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Step, string) error); ok {
r0 = returnFunc(ctx, step, taskUUID)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockBackend_StartStep_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartStep'
type MockBackend_StartStep_Call struct {
*mock.Call
}
// StartStep is a helper method to define mock.On call
// - ctx context.Context
// - step *types.Step
// - taskUUID string
func (_e *MockBackend_Expecter) StartStep(ctx interface{}, step interface{}, taskUUID interface{}) *MockBackend_StartStep_Call {
return &MockBackend_StartStep_Call{Call: _e.mock.On("StartStep", ctx, step, taskUUID)}
}
func (_c *MockBackend_StartStep_Call) Run(run func(ctx context.Context, step *types.Step, taskUUID string)) *MockBackend_StartStep_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 *types.Step
if args[1] != nil {
arg1 = args[1].(*types.Step)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockBackend_StartStep_Call) Return(err error) *MockBackend_StartStep_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockBackend_StartStep_Call) RunAndReturn(run func(ctx context.Context, step *types.Step, taskUUID string) error) *MockBackend_StartStep_Call {
_c.Call.Return(run)
return _c
}
// TailStep provides a mock function for the type MockBackend
func (_mock *MockBackend) TailStep(ctx context.Context, step *types.Step, taskUUID string) (io.ReadCloser, error) {
ret := _mock.Called(ctx, step, taskUUID)
if len(ret) == 0 {
panic("no return value specified for TailStep")
}
var r0 io.ReadCloser
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Step, string) (io.ReadCloser, error)); ok {
return returnFunc(ctx, step, taskUUID)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Step, string) io.ReadCloser); ok {
r0 = returnFunc(ctx, step, taskUUID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(io.ReadCloser)
}
}
if returnFunc, ok := ret.Get(1).(func(context.Context, *types.Step, string) error); ok {
r1 = returnFunc(ctx, step, taskUUID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockBackend_TailStep_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'TailStep'
type MockBackend_TailStep_Call struct {
*mock.Call
}
// TailStep is a helper method to define mock.On call
// - ctx context.Context
// - step *types.Step
// - taskUUID string
func (_e *MockBackend_Expecter) TailStep(ctx interface{}, step interface{}, taskUUID interface{}) *MockBackend_TailStep_Call {
return &MockBackend_TailStep_Call{Call: _e.mock.On("TailStep", ctx, step, taskUUID)}
}
func (_c *MockBackend_TailStep_Call) Run(run func(ctx context.Context, step *types.Step, taskUUID string)) *MockBackend_TailStep_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 *types.Step
if args[1] != nil {
arg1 = args[1].(*types.Step)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockBackend_TailStep_Call) Return(readCloser io.ReadCloser, err error) *MockBackend_TailStep_Call {
_c.Call.Return(readCloser, err)
return _c
}
func (_c *MockBackend_TailStep_Call) RunAndReturn(run func(ctx context.Context, step *types.Step, taskUUID string) (io.ReadCloser, error)) *MockBackend_TailStep_Call {
_c.Call.Return(run)
return _c
}
// WaitStep provides a mock function for the type MockBackend
func (_mock *MockBackend) WaitStep(ctx context.Context, step *types.Step, taskUUID string) (*types.State, error) {
ret := _mock.Called(ctx, step, taskUUID)
if len(ret) == 0 {
panic("no return value specified for WaitStep")
}
var r0 *types.State
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Step, string) (*types.State, error)); ok {
return returnFunc(ctx, step, taskUUID)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, *types.Step, string) *types.State); ok {
r0 = returnFunc(ctx, step, taskUUID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.State)
}
}
if returnFunc, ok := ret.Get(1).(func(context.Context, *types.Step, string) error); ok {
r1 = returnFunc(ctx, step, taskUUID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockBackend_WaitStep_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitStep'
type MockBackend_WaitStep_Call struct {
*mock.Call
}
// WaitStep is a helper method to define mock.On call
// - ctx context.Context
// - step *types.Step
// - taskUUID string
func (_e *MockBackend_Expecter) WaitStep(ctx interface{}, step interface{}, taskUUID interface{}) *MockBackend_WaitStep_Call {
return &MockBackend_WaitStep_Call{Call: _e.mock.On("WaitStep", ctx, step, taskUUID)}
}
func (_c *MockBackend_WaitStep_Call) Run(run func(ctx context.Context, step *types.Step, taskUUID string)) *MockBackend_WaitStep_Call {
_c.Call.Run(func(args mock.Arguments) {
var arg0 context.Context
if args[0] != nil {
arg0 = args[0].(context.Context)
}
var arg1 *types.Step
if args[1] != nil {
arg1 = args[1].(*types.Step)
}
var arg2 string
if args[2] != nil {
arg2 = args[2].(string)
}
run(
arg0,
arg1,
arg2,
)
})
return _c
}
func (_c *MockBackend_WaitStep_Call) Return(state *types.State, err error) *MockBackend_WaitStep_Call {
_c.Call.Return(state, err)
return _c
}
func (_c *MockBackend_WaitStep_Call) RunAndReturn(run func(ctx context.Context, step *types.Step, taskUUID string) (*types.State, error)) *MockBackend_WaitStep_Call {
_c.Call.Return(run)
return _c
}