diff --git a/runner/interfaces.go b/runner/interfaces.go index fa810e6b..9bb375c3 100644 --- a/runner/interfaces.go +++ b/runner/interfaces.go @@ -21,6 +21,8 @@ import ( "garm/runner/common" ) +//go:generate mockery --name=PoolManagerController + type PoolManagerController interface { CreateRepoPoolManager(ctx context.Context, repo params.Repository, providers map[string]common.Provider, store dbCommon.Store) (common.PoolManager, error) GetRepoPoolManager(repo params.Repository) (common.PoolManager, error) diff --git a/runner/mocks/poolManagerController.go b/runner/mocks/poolManagerController.go new file mode 100644 index 00000000..2c25948b --- /dev/null +++ b/runner/mocks/poolManagerController.go @@ -0,0 +1,168 @@ +// Code generated by mockery v2.14.0. DO NOT EDIT. + +package mocks + +import ( + context "context" + common "garm/runner/common" + + databasecommon "garm/database/common" + + mock "github.com/stretchr/testify/mock" + + params "garm/params" +) + +// PoolManagerController is an autogenerated mock type for the PoolManagerController type +type PoolManagerController struct { + mock.Mock +} + +// CreateOrgPoolManager provides a mock function with given fields: ctx, org, providers, store +func (_m *PoolManagerController) CreateOrgPoolManager(ctx context.Context, org params.Organization, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) { + ret := _m.Called(ctx, org, providers, store) + + var r0 common.PoolManager + if rf, ok := ret.Get(0).(func(context.Context, params.Organization, map[string]common.Provider, databasecommon.Store) common.PoolManager); ok { + r0 = rf(ctx, org, providers, store) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, params.Organization, map[string]common.Provider, databasecommon.Store) error); ok { + r1 = rf(ctx, org, providers, store) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// CreateRepoPoolManager provides a mock function with given fields: ctx, repo, providers, store +func (_m *PoolManagerController) CreateRepoPoolManager(ctx context.Context, repo params.Repository, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) { + ret := _m.Called(ctx, repo, providers, store) + + var r0 common.PoolManager + if rf, ok := ret.Get(0).(func(context.Context, params.Repository, map[string]common.Provider, databasecommon.Store) common.PoolManager); ok { + r0 = rf(ctx, repo, providers, store) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, params.Repository, map[string]common.Provider, databasecommon.Store) error); ok { + r1 = rf(ctx, repo, providers, store) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// DeleteOrgPoolManager provides a mock function with given fields: org +func (_m *PoolManagerController) DeleteOrgPoolManager(org params.Organization) { + _m.Called(org) +} + +// DeleteRepoPoolManager provides a mock function with given fields: repo +func (_m *PoolManagerController) DeleteRepoPoolManager(repo params.Repository) { + _m.Called(repo) +} + +// GetOrgPoolManager provides a mock function with given fields: org +func (_m *PoolManagerController) GetOrgPoolManager(org params.Organization) (common.PoolManager, error) { + ret := _m.Called(org) + + var r0 common.PoolManager + if rf, ok := ret.Get(0).(func(params.Organization) common.PoolManager); ok { + r0 = rf(org) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(params.Organization) error); ok { + r1 = rf(org) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetOrgPoolManagers provides a mock function with given fields: +func (_m *PoolManagerController) GetOrgPoolManagers() map[string]common.PoolManager { + ret := _m.Called() + + var r0 map[string]common.PoolManager + if rf, ok := ret.Get(0).(func() map[string]common.PoolManager); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]common.PoolManager) + } + } + + return r0 +} + +// GetRepoPoolManager provides a mock function with given fields: repo +func (_m *PoolManagerController) GetRepoPoolManager(repo params.Repository) (common.PoolManager, error) { + ret := _m.Called(repo) + + var r0 common.PoolManager + if rf, ok := ret.Get(0).(func(params.Repository) common.PoolManager); ok { + r0 = rf(repo) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.PoolManager) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(params.Repository) error); ok { + r1 = rf(repo) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetRepoPoolManagers provides a mock function with given fields: +func (_m *PoolManagerController) GetRepoPoolManagers() map[string]common.PoolManager { + ret := _m.Called() + + var r0 map[string]common.PoolManager + if rf, ok := ret.Get(0).(func() map[string]common.PoolManager); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(map[string]common.PoolManager) + } + } + + return r0 +} + +type mockConstructorTestingTNewPoolManagerController interface { + mock.TestingT + Cleanup(func()) +} + +// NewPoolManagerController creates a new instance of PoolManagerController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +func NewPoolManagerController(t mockConstructorTestingTNewPoolManagerController) *PoolManagerController { + mock := &PoolManagerController{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}