diff --git a/.mockery.yaml b/.mockery.yml similarity index 51% rename from .mockery.yaml rename to .mockery.yml index aa8812cd9b..2f61192c52 100644 --- a/.mockery.yaml +++ b/.mockery.yml @@ -1,8 +1,28 @@ -quiet: false mockname: "{{.InterfaceName}}" filename: "{{.InterfaceName}}.go" +dir: "{{.InterfaceDir}}/mocks" outpkg: mocks +quiet: false packages: + github.com/SAP/jenkins-library/cmd: + interfaces: + GithubRepoClient: + HadolintPiperFileUtils: + HadolintClient: + github.com/SAP/jenkins-library/pkg/config: + interfaces: + VaultClient: + github.com/SAP/jenkins-library/pkg/jenkins: + interfaces: + Artifact: + Build: + CredentialsManager: + Jenkins: + Job: + Task: + github.com/SAP/jenkins-library/pkg/kubernetes: + interfaces: + HelmExecutor: github.com/influxdata/influxdb-client-go/v2: config: dir: pkg/influx/mocks @@ -13,8 +33,3 @@ packages: dir: pkg/influx/mocks interfaces: WriteAPIBlocking: - github.com/SAP/jenkins-library/pkg/config: - config: - dir: pkg/config/mocks - interfaces: - VaultClient: diff --git a/cmd/githubPublishRelease.go b/cmd/githubPublishRelease.go index 8f14adc03d..2267b841cb 100644 --- a/cmd/githubPublishRelease.go +++ b/cmd/githubPublishRelease.go @@ -16,7 +16,6 @@ import ( piperGithub "github.com/SAP/jenkins-library/pkg/github" ) -// mock generated with: mockery --name GithubRepoClient --dir cmd --output cmd/mocks type GithubRepoClient interface { CreateRelease(ctx context.Context, owner string, repo string, release *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error) DeleteReleaseAsset(ctx context.Context, owner string, repo string, id int64) (*github.Response, error) diff --git a/cmd/hadolintExecute.go b/cmd/hadolintExecute.go index 6eb66bcdee..fcfcf4f3a0 100644 --- a/cmd/hadolintExecute.go +++ b/cmd/hadolintExecute.go @@ -18,7 +18,6 @@ import ( const hadolintCommand = "hadolint" // HadolintPiperFileUtils abstracts piperutils.Files -// mock generated with: mockery --name HadolintPiperFileUtils --dir cmd --output pkg/hadolint/mocks type HadolintPiperFileUtils interface { FileExists(filename string) (bool, error) FileWrite(filename string, data []byte, perm os.FileMode) error @@ -26,7 +25,6 @@ type HadolintPiperFileUtils interface { } // HadolintClient abstracts http.Client -// mock generated with: mockery --name hadolintClient --dir cmd --output pkg/hadolint/mocks type HadolintClient interface { SetOptions(options piperhttp.ClientOptions) DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error diff --git a/cmd/hadolintExecute_test.go b/cmd/hadolintExecute_test.go index f1c1c0921d..11422c157d 100644 --- a/cmd/hadolintExecute_test.go +++ b/cmd/hadolintExecute_test.go @@ -6,7 +6,7 @@ package cmd import ( "testing" - "github.com/SAP/jenkins-library/pkg/hadolint/mocks" + "github.com/SAP/jenkins-library/cmd/mocks" piperMocks "github.com/SAP/jenkins-library/pkg/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/cmd/mocks/GithubRepoClient.go b/cmd/mocks/GithubRepoClient.go index 625ed61c9f..3c8394915a 100644 --- a/cmd/mocks/GithubRepoClient.go +++ b/cmd/mocks/GithubRepoClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.10.4. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -16,11 +16,28 @@ type GithubRepoClient struct { mock.Mock } +type GithubRepoClient_Expecter struct { + mock *mock.Mock +} + +func (_m *GithubRepoClient) EXPECT() *GithubRepoClient_Expecter { + return &GithubRepoClient_Expecter{mock: &_m.Mock} +} + // CreateRelease provides a mock function with given fields: ctx, owner, repo, release func (_m *GithubRepoClient) CreateRelease(ctx context.Context, owner string, repo string, release *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error) { ret := _m.Called(ctx, owner, repo, release) + if len(ret) == 0 { + panic("no return value specified for CreateRelease") + } + var r0 *github.RepositoryRelease + var r1 *github.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error)); ok { + return rf(ctx, owner, repo, release) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, *github.RepositoryRelease) *github.RepositoryRelease); ok { r0 = rf(ctx, owner, repo, release) } else { @@ -29,7 +46,6 @@ func (_m *GithubRepoClient) CreateRelease(ctx context.Context, owner string, rep } } - var r1 *github.Response if rf, ok := ret.Get(1).(func(context.Context, string, string, *github.RepositoryRelease) *github.Response); ok { r1 = rf(ctx, owner, repo, release) } else { @@ -38,7 +54,6 @@ func (_m *GithubRepoClient) CreateRelease(ctx context.Context, owner string, rep } } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, string, string, *github.RepositoryRelease) error); ok { r2 = rf(ctx, owner, repo, release) } else { @@ -48,11 +63,50 @@ func (_m *GithubRepoClient) CreateRelease(ctx context.Context, owner string, rep return r0, r1, r2 } +// GithubRepoClient_CreateRelease_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateRelease' +type GithubRepoClient_CreateRelease_Call struct { + *mock.Call +} + +// CreateRelease is a helper method to define mock.On call +// - ctx context.Context +// - owner string +// - repo string +// - release *github.RepositoryRelease +func (_e *GithubRepoClient_Expecter) CreateRelease(ctx interface{}, owner interface{}, repo interface{}, release interface{}) *GithubRepoClient_CreateRelease_Call { + return &GithubRepoClient_CreateRelease_Call{Call: _e.mock.On("CreateRelease", ctx, owner, repo, release)} +} + +func (_c *GithubRepoClient_CreateRelease_Call) Run(run func(ctx context.Context, owner string, repo string, release *github.RepositoryRelease)) *GithubRepoClient_CreateRelease_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(*github.RepositoryRelease)) + }) + return _c +} + +func (_c *GithubRepoClient_CreateRelease_Call) Return(_a0 *github.RepositoryRelease, _a1 *github.Response, _a2 error) *GithubRepoClient_CreateRelease_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *GithubRepoClient_CreateRelease_Call) RunAndReturn(run func(context.Context, string, string, *github.RepositoryRelease) (*github.RepositoryRelease, *github.Response, error)) *GithubRepoClient_CreateRelease_Call { + _c.Call.Return(run) + return _c +} + // DeleteReleaseAsset provides a mock function with given fields: ctx, owner, repo, id func (_m *GithubRepoClient) DeleteReleaseAsset(ctx context.Context, owner string, repo string, id int64) (*github.Response, error) { ret := _m.Called(ctx, owner, repo, id) + if len(ret) == 0 { + panic("no return value specified for DeleteReleaseAsset") + } + var r0 *github.Response + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) (*github.Response, error)); ok { + return rf(ctx, owner, repo, id) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) *github.Response); ok { r0 = rf(ctx, owner, repo, id) } else { @@ -61,7 +115,6 @@ func (_m *GithubRepoClient) DeleteReleaseAsset(ctx context.Context, owner string } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, string, int64) error); ok { r1 = rf(ctx, owner, repo, id) } else { @@ -71,11 +124,51 @@ func (_m *GithubRepoClient) DeleteReleaseAsset(ctx context.Context, owner string return r0, r1 } +// GithubRepoClient_DeleteReleaseAsset_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteReleaseAsset' +type GithubRepoClient_DeleteReleaseAsset_Call struct { + *mock.Call +} + +// DeleteReleaseAsset is a helper method to define mock.On call +// - ctx context.Context +// - owner string +// - repo string +// - id int64 +func (_e *GithubRepoClient_Expecter) DeleteReleaseAsset(ctx interface{}, owner interface{}, repo interface{}, id interface{}) *GithubRepoClient_DeleteReleaseAsset_Call { + return &GithubRepoClient_DeleteReleaseAsset_Call{Call: _e.mock.On("DeleteReleaseAsset", ctx, owner, repo, id)} +} + +func (_c *GithubRepoClient_DeleteReleaseAsset_Call) Run(run func(ctx context.Context, owner string, repo string, id int64)) *GithubRepoClient_DeleteReleaseAsset_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64)) + }) + return _c +} + +func (_c *GithubRepoClient_DeleteReleaseAsset_Call) Return(_a0 *github.Response, _a1 error) *GithubRepoClient_DeleteReleaseAsset_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *GithubRepoClient_DeleteReleaseAsset_Call) RunAndReturn(run func(context.Context, string, string, int64) (*github.Response, error)) *GithubRepoClient_DeleteReleaseAsset_Call { + _c.Call.Return(run) + return _c +} + // GetLatestRelease provides a mock function with given fields: ctx, owner, repo func (_m *GithubRepoClient) GetLatestRelease(ctx context.Context, owner string, repo string) (*github.RepositoryRelease, *github.Response, error) { ret := _m.Called(ctx, owner, repo) + if len(ret) == 0 { + panic("no return value specified for GetLatestRelease") + } + var r0 *github.RepositoryRelease + var r1 *github.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*github.RepositoryRelease, *github.Response, error)); ok { + return rf(ctx, owner, repo) + } if rf, ok := ret.Get(0).(func(context.Context, string, string) *github.RepositoryRelease); ok { r0 = rf(ctx, owner, repo) } else { @@ -84,7 +177,6 @@ func (_m *GithubRepoClient) GetLatestRelease(ctx context.Context, owner string, } } - var r1 *github.Response if rf, ok := ret.Get(1).(func(context.Context, string, string) *github.Response); ok { r1 = rf(ctx, owner, repo) } else { @@ -93,7 +185,6 @@ func (_m *GithubRepoClient) GetLatestRelease(ctx context.Context, owner string, } } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, string, string) error); ok { r2 = rf(ctx, owner, repo) } else { @@ -103,11 +194,50 @@ func (_m *GithubRepoClient) GetLatestRelease(ctx context.Context, owner string, return r0, r1, r2 } +// GithubRepoClient_GetLatestRelease_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestRelease' +type GithubRepoClient_GetLatestRelease_Call struct { + *mock.Call +} + +// GetLatestRelease is a helper method to define mock.On call +// - ctx context.Context +// - owner string +// - repo string +func (_e *GithubRepoClient_Expecter) GetLatestRelease(ctx interface{}, owner interface{}, repo interface{}) *GithubRepoClient_GetLatestRelease_Call { + return &GithubRepoClient_GetLatestRelease_Call{Call: _e.mock.On("GetLatestRelease", ctx, owner, repo)} +} + +func (_c *GithubRepoClient_GetLatestRelease_Call) Run(run func(ctx context.Context, owner string, repo string)) *GithubRepoClient_GetLatestRelease_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *GithubRepoClient_GetLatestRelease_Call) Return(_a0 *github.RepositoryRelease, _a1 *github.Response, _a2 error) *GithubRepoClient_GetLatestRelease_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *GithubRepoClient_GetLatestRelease_Call) RunAndReturn(run func(context.Context, string, string) (*github.RepositoryRelease, *github.Response, error)) *GithubRepoClient_GetLatestRelease_Call { + _c.Call.Return(run) + return _c +} + // ListReleaseAssets provides a mock function with given fields: ctx, owner, repo, id, opt func (_m *GithubRepoClient) ListReleaseAssets(ctx context.Context, owner string, repo string, id int64, opt *github.ListOptions) ([]*github.ReleaseAsset, *github.Response, error) { ret := _m.Called(ctx, owner, repo, id, opt) + if len(ret) == 0 { + panic("no return value specified for ListReleaseAssets") + } + var r0 []*github.ReleaseAsset + var r1 *github.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *github.ListOptions) ([]*github.ReleaseAsset, *github.Response, error)); ok { + return rf(ctx, owner, repo, id, opt) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *github.ListOptions) []*github.ReleaseAsset); ok { r0 = rf(ctx, owner, repo, id, opt) } else { @@ -116,7 +246,6 @@ func (_m *GithubRepoClient) ListReleaseAssets(ctx context.Context, owner string, } } - var r1 *github.Response if rf, ok := ret.Get(1).(func(context.Context, string, string, int64, *github.ListOptions) *github.Response); ok { r1 = rf(ctx, owner, repo, id, opt) } else { @@ -125,7 +254,6 @@ func (_m *GithubRepoClient) ListReleaseAssets(ctx context.Context, owner string, } } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, string, string, int64, *github.ListOptions) error); ok { r2 = rf(ctx, owner, repo, id, opt) } else { @@ -135,11 +263,52 @@ func (_m *GithubRepoClient) ListReleaseAssets(ctx context.Context, owner string, return r0, r1, r2 } +// GithubRepoClient_ListReleaseAssets_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListReleaseAssets' +type GithubRepoClient_ListReleaseAssets_Call struct { + *mock.Call +} + +// ListReleaseAssets is a helper method to define mock.On call +// - ctx context.Context +// - owner string +// - repo string +// - id int64 +// - opt *github.ListOptions +func (_e *GithubRepoClient_Expecter) ListReleaseAssets(ctx interface{}, owner interface{}, repo interface{}, id interface{}, opt interface{}) *GithubRepoClient_ListReleaseAssets_Call { + return &GithubRepoClient_ListReleaseAssets_Call{Call: _e.mock.On("ListReleaseAssets", ctx, owner, repo, id, opt)} +} + +func (_c *GithubRepoClient_ListReleaseAssets_Call) Run(run func(ctx context.Context, owner string, repo string, id int64, opt *github.ListOptions)) *GithubRepoClient_ListReleaseAssets_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64), args[4].(*github.ListOptions)) + }) + return _c +} + +func (_c *GithubRepoClient_ListReleaseAssets_Call) Return(_a0 []*github.ReleaseAsset, _a1 *github.Response, _a2 error) *GithubRepoClient_ListReleaseAssets_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *GithubRepoClient_ListReleaseAssets_Call) RunAndReturn(run func(context.Context, string, string, int64, *github.ListOptions) ([]*github.ReleaseAsset, *github.Response, error)) *GithubRepoClient_ListReleaseAssets_Call { + _c.Call.Return(run) + return _c +} + // UploadReleaseAsset provides a mock function with given fields: ctx, owner, repo, id, opt, file func (_m *GithubRepoClient) UploadReleaseAsset(ctx context.Context, owner string, repo string, id int64, opt *github.UploadOptions, file *os.File) (*github.ReleaseAsset, *github.Response, error) { ret := _m.Called(ctx, owner, repo, id, opt, file) + if len(ret) == 0 { + panic("no return value specified for UploadReleaseAsset") + } + var r0 *github.ReleaseAsset + var r1 *github.Response + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *github.UploadOptions, *os.File) (*github.ReleaseAsset, *github.Response, error)); ok { + return rf(ctx, owner, repo, id, opt, file) + } if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *github.UploadOptions, *os.File) *github.ReleaseAsset); ok { r0 = rf(ctx, owner, repo, id, opt, file) } else { @@ -148,7 +317,6 @@ func (_m *GithubRepoClient) UploadReleaseAsset(ctx context.Context, owner string } } - var r1 *github.Response if rf, ok := ret.Get(1).(func(context.Context, string, string, int64, *github.UploadOptions, *os.File) *github.Response); ok { r1 = rf(ctx, owner, repo, id, opt, file) } else { @@ -157,7 +325,6 @@ func (_m *GithubRepoClient) UploadReleaseAsset(ctx context.Context, owner string } } - var r2 error if rf, ok := ret.Get(2).(func(context.Context, string, string, int64, *github.UploadOptions, *os.File) error); ok { r2 = rf(ctx, owner, repo, id, opt, file) } else { @@ -166,3 +333,50 @@ func (_m *GithubRepoClient) UploadReleaseAsset(ctx context.Context, owner string return r0, r1, r2 } + +// GithubRepoClient_UploadReleaseAsset_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UploadReleaseAsset' +type GithubRepoClient_UploadReleaseAsset_Call struct { + *mock.Call +} + +// UploadReleaseAsset is a helper method to define mock.On call +// - ctx context.Context +// - owner string +// - repo string +// - id int64 +// - opt *github.UploadOptions +// - file *os.File +func (_e *GithubRepoClient_Expecter) UploadReleaseAsset(ctx interface{}, owner interface{}, repo interface{}, id interface{}, opt interface{}, file interface{}) *GithubRepoClient_UploadReleaseAsset_Call { + return &GithubRepoClient_UploadReleaseAsset_Call{Call: _e.mock.On("UploadReleaseAsset", ctx, owner, repo, id, opt, file)} +} + +func (_c *GithubRepoClient_UploadReleaseAsset_Call) Run(run func(ctx context.Context, owner string, repo string, id int64, opt *github.UploadOptions, file *os.File)) *GithubRepoClient_UploadReleaseAsset_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64), args[4].(*github.UploadOptions), args[5].(*os.File)) + }) + return _c +} + +func (_c *GithubRepoClient_UploadReleaseAsset_Call) Return(_a0 *github.ReleaseAsset, _a1 *github.Response, _a2 error) *GithubRepoClient_UploadReleaseAsset_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *GithubRepoClient_UploadReleaseAsset_Call) RunAndReturn(run func(context.Context, string, string, int64, *github.UploadOptions, *os.File) (*github.ReleaseAsset, *github.Response, error)) *GithubRepoClient_UploadReleaseAsset_Call { + _c.Call.Return(run) + return _c +} + +// NewGithubRepoClient creates a new instance of GithubRepoClient. 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 NewGithubRepoClient(t interface { + mock.TestingT + Cleanup(func()) +}) *GithubRepoClient { + mock := &GithubRepoClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/mocks/hadolintClient.go b/cmd/mocks/hadolintClient.go new file mode 100644 index 0000000000..4c8eb7131b --- /dev/null +++ b/cmd/mocks/hadolintClient.go @@ -0,0 +1,119 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + pkghttp "github.com/SAP/jenkins-library/pkg/http" + mock "github.com/stretchr/testify/mock" +) + +// HadolintClient is an autogenerated mock type for the HadolintClient type +type HadolintClient struct { + mock.Mock +} + +type HadolintClient_Expecter struct { + mock *mock.Mock +} + +func (_m *HadolintClient) EXPECT() *HadolintClient_Expecter { + return &HadolintClient_Expecter{mock: &_m.Mock} +} + +// DownloadFile provides a mock function with given fields: url, filename, header, cookies +func (_m *HadolintClient) DownloadFile(url string, filename string, header http.Header, cookies []*http.Cookie) error { + ret := _m.Called(url, filename, header, cookies) + + if len(ret) == 0 { + panic("no return value specified for DownloadFile") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, string, http.Header, []*http.Cookie) error); ok { + r0 = rf(url, filename, header, cookies) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// HadolintClient_DownloadFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DownloadFile' +type HadolintClient_DownloadFile_Call struct { + *mock.Call +} + +// DownloadFile is a helper method to define mock.On call +// - url string +// - filename string +// - header http.Header +// - cookies []*http.Cookie +func (_e *HadolintClient_Expecter) DownloadFile(url interface{}, filename interface{}, header interface{}, cookies interface{}) *HadolintClient_DownloadFile_Call { + return &HadolintClient_DownloadFile_Call{Call: _e.mock.On("DownloadFile", url, filename, header, cookies)} +} + +func (_c *HadolintClient_DownloadFile_Call) Run(run func(url string, filename string, header http.Header, cookies []*http.Cookie)) *HadolintClient_DownloadFile_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string), args[2].(http.Header), args[3].([]*http.Cookie)) + }) + return _c +} + +func (_c *HadolintClient_DownloadFile_Call) Return(_a0 error) *HadolintClient_DownloadFile_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HadolintClient_DownloadFile_Call) RunAndReturn(run func(string, string, http.Header, []*http.Cookie) error) *HadolintClient_DownloadFile_Call { + _c.Call.Return(run) + return _c +} + +// SetOptions provides a mock function with given fields: options +func (_m *HadolintClient) SetOptions(options pkghttp.ClientOptions) { + _m.Called(options) +} + +// HadolintClient_SetOptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOptions' +type HadolintClient_SetOptions_Call struct { + *mock.Call +} + +// SetOptions is a helper method to define mock.On call +// - options pkghttp.ClientOptions +func (_e *HadolintClient_Expecter) SetOptions(options interface{}) *HadolintClient_SetOptions_Call { + return &HadolintClient_SetOptions_Call{Call: _e.mock.On("SetOptions", options)} +} + +func (_c *HadolintClient_SetOptions_Call) Run(run func(options pkghttp.ClientOptions)) *HadolintClient_SetOptions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(pkghttp.ClientOptions)) + }) + return _c +} + +func (_c *HadolintClient_SetOptions_Call) Return() *HadolintClient_SetOptions_Call { + _c.Call.Return() + return _c +} + +func (_c *HadolintClient_SetOptions_Call) RunAndReturn(run func(pkghttp.ClientOptions)) *HadolintClient_SetOptions_Call { + _c.Call.Return(run) + return _c +} + +// NewHadolintClient creates a new instance of HadolintClient. 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 NewHadolintClient(t interface { + mock.TestingT + Cleanup(func()) +}) *HadolintClient { + mock := &HadolintClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/cmd/mocks/hadolintPiperFileUtils.go b/cmd/mocks/hadolintPiperFileUtils.go new file mode 100644 index 0000000000..5ef9b46edb --- /dev/null +++ b/cmd/mocks/hadolintPiperFileUtils.go @@ -0,0 +1,188 @@ +// Code generated by mockery v2.43.0. DO NOT EDIT. + +package mocks + +import ( + fs "io/fs" + + mock "github.com/stretchr/testify/mock" +) + +// HadolintPiperFileUtils is an autogenerated mock type for the HadolintPiperFileUtils type +type HadolintPiperFileUtils struct { + mock.Mock +} + +type HadolintPiperFileUtils_Expecter struct { + mock *mock.Mock +} + +func (_m *HadolintPiperFileUtils) EXPECT() *HadolintPiperFileUtils_Expecter { + return &HadolintPiperFileUtils_Expecter{mock: &_m.Mock} +} + +// FileExists provides a mock function with given fields: filename +func (_m *HadolintPiperFileUtils) FileExists(filename string) (bool, error) { + ret := _m.Called(filename) + + if len(ret) == 0 { + panic("no return value specified for FileExists") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(string) (bool, error)); ok { + return rf(filename) + } + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(filename) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(filename) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// HadolintPiperFileUtils_FileExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FileExists' +type HadolintPiperFileUtils_FileExists_Call struct { + *mock.Call +} + +// FileExists is a helper method to define mock.On call +// - filename string +func (_e *HadolintPiperFileUtils_Expecter) FileExists(filename interface{}) *HadolintPiperFileUtils_FileExists_Call { + return &HadolintPiperFileUtils_FileExists_Call{Call: _e.mock.On("FileExists", filename)} +} + +func (_c *HadolintPiperFileUtils_FileExists_Call) Run(run func(filename string)) *HadolintPiperFileUtils_FileExists_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *HadolintPiperFileUtils_FileExists_Call) Return(_a0 bool, _a1 error) *HadolintPiperFileUtils_FileExists_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *HadolintPiperFileUtils_FileExists_Call) RunAndReturn(run func(string) (bool, error)) *HadolintPiperFileUtils_FileExists_Call { + _c.Call.Return(run) + return _c +} + +// FileWrite provides a mock function with given fields: filename, data, perm +func (_m *HadolintPiperFileUtils) FileWrite(filename string, data []byte, perm fs.FileMode) error { + ret := _m.Called(filename, data, perm) + + if len(ret) == 0 { + panic("no return value specified for FileWrite") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, []byte, fs.FileMode) error); ok { + r0 = rf(filename, data, perm) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// HadolintPiperFileUtils_FileWrite_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FileWrite' +type HadolintPiperFileUtils_FileWrite_Call struct { + *mock.Call +} + +// FileWrite is a helper method to define mock.On call +// - filename string +// - data []byte +// - perm fs.FileMode +func (_e *HadolintPiperFileUtils_Expecter) FileWrite(filename interface{}, data interface{}, perm interface{}) *HadolintPiperFileUtils_FileWrite_Call { + return &HadolintPiperFileUtils_FileWrite_Call{Call: _e.mock.On("FileWrite", filename, data, perm)} +} + +func (_c *HadolintPiperFileUtils_FileWrite_Call) Run(run func(filename string, data []byte, perm fs.FileMode)) *HadolintPiperFileUtils_FileWrite_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].([]byte), args[2].(fs.FileMode)) + }) + return _c +} + +func (_c *HadolintPiperFileUtils_FileWrite_Call) Return(_a0 error) *HadolintPiperFileUtils_FileWrite_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HadolintPiperFileUtils_FileWrite_Call) RunAndReturn(run func(string, []byte, fs.FileMode) error) *HadolintPiperFileUtils_FileWrite_Call { + _c.Call.Return(run) + return _c +} + +// WriteFile provides a mock function with given fields: filename, data, perm +func (_m *HadolintPiperFileUtils) WriteFile(filename string, data []byte, perm fs.FileMode) error { + ret := _m.Called(filename, data, perm) + + if len(ret) == 0 { + panic("no return value specified for WriteFile") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, []byte, fs.FileMode) error); ok { + r0 = rf(filename, data, perm) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// HadolintPiperFileUtils_WriteFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WriteFile' +type HadolintPiperFileUtils_WriteFile_Call struct { + *mock.Call +} + +// WriteFile is a helper method to define mock.On call +// - filename string +// - data []byte +// - perm fs.FileMode +func (_e *HadolintPiperFileUtils_Expecter) WriteFile(filename interface{}, data interface{}, perm interface{}) *HadolintPiperFileUtils_WriteFile_Call { + return &HadolintPiperFileUtils_WriteFile_Call{Call: _e.mock.On("WriteFile", filename, data, perm)} +} + +func (_c *HadolintPiperFileUtils_WriteFile_Call) Run(run func(filename string, data []byte, perm fs.FileMode)) *HadolintPiperFileUtils_WriteFile_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].([]byte), args[2].(fs.FileMode)) + }) + return _c +} + +func (_c *HadolintPiperFileUtils_WriteFile_Call) Return(_a0 error) *HadolintPiperFileUtils_WriteFile_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HadolintPiperFileUtils_WriteFile_Call) RunAndReturn(run func(string, []byte, fs.FileMode) error) *HadolintPiperFileUtils_WriteFile_Call { + _c.Call.Return(run) + return _c +} + +// NewHadolintPiperFileUtils creates a new instance of HadolintPiperFileUtils. 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 NewHadolintPiperFileUtils(t interface { + mock.TestingT + Cleanup(func()) +}) *HadolintPiperFileUtils { + mock := &HadolintPiperFileUtils{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/config/mocks/vaultClient.go b/pkg/config/mocks/vaultClient.go index 3b6b8f9adb..ad6b788578 100644 --- a/pkg/config/mocks/vaultClient.go +++ b/pkg/config/mocks/vaultClient.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks diff --git a/pkg/hadolint/mocks/hadolintClient.go b/pkg/hadolint/mocks/hadolintClient.go deleted file mode 100644 index 465d062a50..0000000000 --- a/pkg/hadolint/mocks/hadolintClient.go +++ /dev/null @@ -1,34 +0,0 @@ -// Code generated by mockery v2.0.0-alpha.13. DO NOT EDIT. - -package mocks - -import ( - http "net/http" - - pkghttp "github.com/SAP/jenkins-library/pkg/http" - mock "github.com/stretchr/testify/mock" -) - -// HadolintClient is an autogenerated mock type for the HadolintClient type -type HadolintClient struct { - mock.Mock -} - -// DownloadFile provides a mock function with given fields: url, filename, header, cookies -func (_m *HadolintClient) DownloadFile(url string, filename string, header http.Header, cookies []*http.Cookie) error { - ret := _m.Called(url, filename, header, cookies) - - var r0 error - if rf, ok := ret.Get(0).(func(string, string, http.Header, []*http.Cookie) error); ok { - r0 = rf(url, filename, header, cookies) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// SetOptions provides a mock function with given fields: options -func (_m *HadolintClient) SetOptions(options pkghttp.ClientOptions) { - _m.Called(options) -} diff --git a/pkg/hadolint/mocks/hadolintPiperFileUtils.go b/pkg/hadolint/mocks/hadolintPiperFileUtils.go deleted file mode 100644 index a16993e8ca..0000000000 --- a/pkg/hadolint/mocks/hadolintPiperFileUtils.go +++ /dev/null @@ -1,62 +0,0 @@ -// Code generated by mockery v2.0.0-alpha.13. DO NOT EDIT. - -package mocks - -import ( - os "os" - - mock "github.com/stretchr/testify/mock" -) - -// HadolintPiperFileUtils is an autogenerated mock type for the HadolintPiperFileUtils type -type HadolintPiperFileUtils struct { - mock.Mock -} - -// FileExists provides a mock function with given fields: filename -func (_m *HadolintPiperFileUtils) FileExists(filename string) (bool, error) { - ret := _m.Called(filename) - - var r0 bool - if rf, ok := ret.Get(0).(func(string) bool); ok { - r0 = rf(filename) - } else { - r0 = ret.Get(0).(bool) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(filename) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// FileWrite provides a mock function with given fields: filename, data, perm -func (_m *HadolintPiperFileUtils) FileWrite(filename string, data []byte, perm os.FileMode) error { - ret := _m.Called(filename, data, perm) - - var r0 error - if rf, ok := ret.Get(0).(func(string, []byte, os.FileMode) error); ok { - r0 = rf(filename, data, perm) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -func (_m *HadolintPiperFileUtils) WriteFile(filename string, data []byte, perm os.FileMode) error { - ret := _m.Called(filename, data, perm) - - var r0 error - if rf, ok := ret.Get(0).(func(string, []byte, os.FileMode) error); ok { - r0 = rf(filename, data, perm) - } else { - r0 = ret.Error(0) - } - - return r0 -} diff --git a/pkg/influx/mocks/Client.go b/pkg/influx/mocks/Client.go index ad616fdefd..491d0f59a1 100644 --- a/pkg/influx/mocks/Client.go +++ b/pkg/influx/mocks/Client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks diff --git a/pkg/influx/mocks/WriteAPIBlocking.go b/pkg/influx/mocks/WriteAPIBlocking.go index bf2549831f..4e898bef17 100644 --- a/pkg/influx/mocks/WriteAPIBlocking.go +++ b/pkg/influx/mocks/WriteAPIBlocking.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.40.1. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks diff --git a/pkg/jenkins/artifact.go b/pkg/jenkins/artifact.go index 478b1e0b0f..6097e9bdf0 100644 --- a/pkg/jenkins/artifact.go +++ b/pkg/jenkins/artifact.go @@ -7,7 +7,6 @@ import ( ) // Artifact is an interface to abstract gojenkins.Artifact. -// mock generated with: mockery --name Artifact --dir pkg/jenkins --output pkg/jenkins/mocks type Artifact interface { Save(ctx context.Context, path string) (bool, error) SaveToDir(ctx context.Context, dir string) (bool, error) diff --git a/pkg/jenkins/build.go b/pkg/jenkins/build.go index 4f693fa4a0..e1278e1ea4 100644 --- a/pkg/jenkins/build.go +++ b/pkg/jenkins/build.go @@ -10,7 +10,6 @@ import ( ) // Build is an interface to abstract gojenkins.Build. -// mock generated with: mockery --name Build --dir pkg/jenkins --output pkg/jenkins/mocks type Build interface { GetArtifacts() []gojenkins.Artifact IsRunning(ctx context.Context) bool diff --git a/pkg/jenkins/credential.go b/pkg/jenkins/credential.go index eb3f6af2ef..4495f727c4 100644 --- a/pkg/jenkins/credential.go +++ b/pkg/jenkins/credential.go @@ -22,7 +22,6 @@ type SSHCredentials = gojenkins.SSHCredentials type DockerServerCredentials = gojenkins.DockerServerCredentials // CredentialsManager is utility to control credential plugin -// mock generated with: mockery --name CredentialsManager --dir pkg/jenkins --output pkg/jenkins/mocks type CredentialsManager interface { Update(context.Context, string, string, interface{}) error } diff --git a/pkg/jenkins/jenkins.go b/pkg/jenkins/jenkins.go index 4cf9c92510..a654fef918 100644 --- a/pkg/jenkins/jenkins.go +++ b/pkg/jenkins/jenkins.go @@ -11,7 +11,6 @@ import ( ) // Jenkins is an interface to abstract gojenkins.Jenkins. -// mock generated with: mockery --name Jenkins --dir pkg/jenkins --output pkg/jenkins/mocks type Jenkins interface { GetJobObj(ctx context.Context, name string) *gojenkins.Job BuildJob(ctx context.Context, name string, params map[string]string) (int64, error) diff --git a/pkg/jenkins/job.go b/pkg/jenkins/job.go index 721aa9e01e..a379a63ba6 100644 --- a/pkg/jenkins/job.go +++ b/pkg/jenkins/job.go @@ -7,7 +7,6 @@ import ( ) // Task is an interface to abstract gojenkins.Task. -// mock generated with: mockery --name Job --dir pkg/jenkins --output pkg/jenkins/mocks type Job interface { Poll(context.Context) (int, error) InvokeSimple(ctx context.Context, params map[string]string) (int64, error) diff --git a/pkg/jenkins/mocks/Artifact.go b/pkg/jenkins/mocks/Artifact.go index 74598f017a..629dcc6897 100644 --- a/pkg/jenkins/mocks/Artifact.go +++ b/pkg/jenkins/mocks/Artifact.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.5. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -13,10 +13,22 @@ type Artifact struct { mock.Mock } +type Artifact_Expecter struct { + mock *mock.Mock +} + +func (_m *Artifact) EXPECT() *Artifact_Expecter { + return &Artifact_Expecter{mock: &_m.Mock} +} + // FileName provides a mock function with given fields: func (_m *Artifact) FileName() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for FileName") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -27,11 +39,46 @@ func (_m *Artifact) FileName() string { return r0 } +// Artifact_FileName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FileName' +type Artifact_FileName_Call struct { + *mock.Call +} + +// FileName is a helper method to define mock.On call +func (_e *Artifact_Expecter) FileName() *Artifact_FileName_Call { + return &Artifact_FileName_Call{Call: _e.mock.On("FileName")} +} + +func (_c *Artifact_FileName_Call) Run(run func()) *Artifact_FileName_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Artifact_FileName_Call) Return(_a0 string) *Artifact_FileName_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Artifact_FileName_Call) RunAndReturn(run func() string) *Artifact_FileName_Call { + _c.Call.Return(run) + return _c +} + // GetData provides a mock function with given fields: ctx func (_m *Artifact) GetData(ctx context.Context) ([]byte, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for GetData") + } + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]byte, error)); ok { + return rf(ctx) + } if rf, ok := ret.Get(0).(func(context.Context) []byte); ok { r0 = rf(ctx) } else { @@ -40,7 +87,6 @@ func (_m *Artifact) GetData(ctx context.Context) ([]byte, error) { } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(ctx) } else { @@ -50,18 +96,53 @@ func (_m *Artifact) GetData(ctx context.Context) ([]byte, error) { return r0, r1 } +// Artifact_GetData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetData' +type Artifact_GetData_Call struct { + *mock.Call +} + +// GetData is a helper method to define mock.On call +// - ctx context.Context +func (_e *Artifact_Expecter) GetData(ctx interface{}) *Artifact_GetData_Call { + return &Artifact_GetData_Call{Call: _e.mock.On("GetData", ctx)} +} + +func (_c *Artifact_GetData_Call) Run(run func(ctx context.Context)) *Artifact_GetData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *Artifact_GetData_Call) Return(_a0 []byte, _a1 error) *Artifact_GetData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Artifact_GetData_Call) RunAndReturn(run func(context.Context) ([]byte, error)) *Artifact_GetData_Call { + _c.Call.Return(run) + return _c +} + // Save provides a mock function with given fields: ctx, path func (_m *Artifact) Save(ctx context.Context, path string) (bool, error) { ret := _m.Called(ctx, path) + if len(ret) == 0 { + panic("no return value specified for Save") + } + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok { + return rf(ctx, path) + } if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { r0 = rf(ctx, path) } else { r0 = ret.Get(0).(bool) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(ctx, path) } else { @@ -71,18 +152,54 @@ func (_m *Artifact) Save(ctx context.Context, path string) (bool, error) { return r0, r1 } +// Artifact_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save' +type Artifact_Save_Call struct { + *mock.Call +} + +// Save is a helper method to define mock.On call +// - ctx context.Context +// - path string +func (_e *Artifact_Expecter) Save(ctx interface{}, path interface{}) *Artifact_Save_Call { + return &Artifact_Save_Call{Call: _e.mock.On("Save", ctx, path)} +} + +func (_c *Artifact_Save_Call) Run(run func(ctx context.Context, path string)) *Artifact_Save_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *Artifact_Save_Call) Return(_a0 bool, _a1 error) *Artifact_Save_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Artifact_Save_Call) RunAndReturn(run func(context.Context, string) (bool, error)) *Artifact_Save_Call { + _c.Call.Return(run) + return _c +} + // SaveToDir provides a mock function with given fields: ctx, dir func (_m *Artifact) SaveToDir(ctx context.Context, dir string) (bool, error) { ret := _m.Called(ctx, dir) + if len(ret) == 0 { + panic("no return value specified for SaveToDir") + } + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok { + return rf(ctx, dir) + } if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { r0 = rf(ctx, dir) } else { r0 = ret.Get(0).(bool) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(ctx, dir) } else { @@ -91,3 +208,46 @@ func (_m *Artifact) SaveToDir(ctx context.Context, dir string) (bool, error) { return r0, r1 } + +// Artifact_SaveToDir_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveToDir' +type Artifact_SaveToDir_Call struct { + *mock.Call +} + +// SaveToDir is a helper method to define mock.On call +// - ctx context.Context +// - dir string +func (_e *Artifact_Expecter) SaveToDir(ctx interface{}, dir interface{}) *Artifact_SaveToDir_Call { + return &Artifact_SaveToDir_Call{Call: _e.mock.On("SaveToDir", ctx, dir)} +} + +func (_c *Artifact_SaveToDir_Call) Run(run func(ctx context.Context, dir string)) *Artifact_SaveToDir_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *Artifact_SaveToDir_Call) Return(_a0 bool, _a1 error) *Artifact_SaveToDir_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Artifact_SaveToDir_Call) RunAndReturn(run func(context.Context, string) (bool, error)) *Artifact_SaveToDir_Call { + _c.Call.Return(run) + return _c +} + +// NewArtifact creates a new instance of Artifact. 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 NewArtifact(t interface { + mock.TestingT + Cleanup(func()) +}) *Artifact { + mock := &Artifact{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/jenkins/mocks/Build.go b/pkg/jenkins/mocks/Build.go index 302bbeaf70..03c8731c4b 100644 --- a/pkg/jenkins/mocks/Build.go +++ b/pkg/jenkins/mocks/Build.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.5. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -15,10 +15,22 @@ type Build struct { mock.Mock } +type Build_Expecter struct { + mock *mock.Mock +} + +func (_m *Build) EXPECT() *Build_Expecter { + return &Build_Expecter{mock: &_m.Mock} +} + // GetArtifacts provides a mock function with given fields: func (_m *Build) GetArtifacts() []gojenkins.Artifact { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetArtifacts") + } + var r0 []gojenkins.Artifact if rf, ok := ret.Get(0).(func() []gojenkins.Artifact); ok { r0 = rf() @@ -31,10 +43,41 @@ func (_m *Build) GetArtifacts() []gojenkins.Artifact { return r0 } +// Build_GetArtifacts_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetArtifacts' +type Build_GetArtifacts_Call struct { + *mock.Call +} + +// GetArtifacts is a helper method to define mock.On call +func (_e *Build_Expecter) GetArtifacts() *Build_GetArtifacts_Call { + return &Build_GetArtifacts_Call{Call: _e.mock.On("GetArtifacts")} +} + +func (_c *Build_GetArtifacts_Call) Run(run func()) *Build_GetArtifacts_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Build_GetArtifacts_Call) Return(_a0 []gojenkins.Artifact) *Build_GetArtifacts_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Build_GetArtifacts_Call) RunAndReturn(run func() []gojenkins.Artifact) *Build_GetArtifacts_Call { + _c.Call.Return(run) + return _c +} + // IsRunning provides a mock function with given fields: ctx func (_m *Build) IsRunning(ctx context.Context) bool { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func(context.Context) bool); ok { r0 = rf(ctx) @@ -45,6 +88,34 @@ func (_m *Build) IsRunning(ctx context.Context) bool { return r0 } +// Build_IsRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsRunning' +type Build_IsRunning_Call struct { + *mock.Call +} + +// IsRunning is a helper method to define mock.On call +// - ctx context.Context +func (_e *Build_Expecter) IsRunning(ctx interface{}) *Build_IsRunning_Call { + return &Build_IsRunning_Call{Call: _e.mock.On("IsRunning", ctx)} +} + +func (_c *Build_IsRunning_Call) Run(run func(ctx context.Context)) *Build_IsRunning_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *Build_IsRunning_Call) Return(_a0 bool) *Build_IsRunning_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Build_IsRunning_Call) RunAndReturn(run func(context.Context) bool) *Build_IsRunning_Call { + _c.Call.Return(run) + return _c +} + // Poll provides a mock function with given fields: ctx, options func (_m *Build) Poll(ctx context.Context, options ...interface{}) (int, error) { var _ca []interface{} @@ -52,14 +123,21 @@ func (_m *Build) Poll(ctx context.Context, options ...interface{}) (int, error) _ca = append(_ca, options...) ret := _m.Called(_ca...) + if len(ret) == 0 { + panic("no return value specified for Poll") + } + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, ...interface{}) (int, error)); ok { + return rf(ctx, options...) + } if rf, ok := ret.Get(0).(func(context.Context, ...interface{}) int); ok { r0 = rf(ctx, options...) } else { r0 = ret.Get(0).(int) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, ...interface{}) error); ok { r1 = rf(ctx, options...) } else { @@ -68,3 +146,53 @@ func (_m *Build) Poll(ctx context.Context, options ...interface{}) (int, error) return r0, r1 } + +// Build_Poll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Poll' +type Build_Poll_Call struct { + *mock.Call +} + +// Poll is a helper method to define mock.On call +// - ctx context.Context +// - options ...interface{} +func (_e *Build_Expecter) Poll(ctx interface{}, options ...interface{}) *Build_Poll_Call { + return &Build_Poll_Call{Call: _e.mock.On("Poll", + append([]interface{}{ctx}, options...)...)} +} + +func (_c *Build_Poll_Call) Run(run func(ctx context.Context, options ...interface{})) *Build_Poll_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]interface{}, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(interface{}) + } + } + run(args[0].(context.Context), variadicArgs...) + }) + return _c +} + +func (_c *Build_Poll_Call) Return(_a0 int, _a1 error) *Build_Poll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Build_Poll_Call) RunAndReturn(run func(context.Context, ...interface{}) (int, error)) *Build_Poll_Call { + _c.Call.Return(run) + return _c +} + +// NewBuild creates a new instance of Build. 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 NewBuild(t interface { + mock.TestingT + Cleanup(func()) +}) *Build { + mock := &Build{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/jenkins/mocks/CredentialsManager.go b/pkg/jenkins/mocks/CredentialsManager.go index c1bd2b21d6..b4f4392099 100644 --- a/pkg/jenkins/mocks/CredentialsManager.go +++ b/pkg/jenkins/mocks/CredentialsManager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.5. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -13,10 +13,22 @@ type CredentialsManager struct { mock.Mock } +type CredentialsManager_Expecter struct { + mock *mock.Mock +} + +func (_m *CredentialsManager) EXPECT() *CredentialsManager_Expecter { + return &CredentialsManager_Expecter{mock: &_m.Mock} +} + // Update provides a mock function with given fields: _a0, _a1, _a2, _a3 func (_m *CredentialsManager) Update(_a0 context.Context, _a1 string, _a2 string, _a3 interface{}) error { ret := _m.Called(_a0, _a1, _a2, _a3) + if len(ret) == 0 { + panic("no return value specified for Update") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string, interface{}) error); ok { r0 = rf(_a0, _a1, _a2, _a3) @@ -26,3 +38,48 @@ func (_m *CredentialsManager) Update(_a0 context.Context, _a1 string, _a2 string return r0 } + +// CredentialsManager_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type CredentialsManager_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - _a0 context.Context +// - _a1 string +// - _a2 string +// - _a3 interface{} +func (_e *CredentialsManager_Expecter) Update(_a0 interface{}, _a1 interface{}, _a2 interface{}, _a3 interface{}) *CredentialsManager_Update_Call { + return &CredentialsManager_Update_Call{Call: _e.mock.On("Update", _a0, _a1, _a2, _a3)} +} + +func (_c *CredentialsManager_Update_Call) Run(run func(_a0 context.Context, _a1 string, _a2 string, _a3 interface{})) *CredentialsManager_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(interface{})) + }) + return _c +} + +func (_c *CredentialsManager_Update_Call) Return(_a0 error) *CredentialsManager_Update_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CredentialsManager_Update_Call) RunAndReturn(run func(context.Context, string, string, interface{}) error) *CredentialsManager_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewCredentialsManager creates a new instance of CredentialsManager. 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 NewCredentialsManager(t interface { + mock.TestingT + Cleanup(func()) +}) *CredentialsManager { + mock := &CredentialsManager{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/jenkins/mocks/Jenkins.go b/pkg/jenkins/mocks/Jenkins.go index 2903b97a92..8fb92f5bcc 100644 --- a/pkg/jenkins/mocks/Jenkins.go +++ b/pkg/jenkins/mocks/Jenkins.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.5. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -15,18 +15,33 @@ type Jenkins struct { mock.Mock } +type Jenkins_Expecter struct { + mock *mock.Mock +} + +func (_m *Jenkins) EXPECT() *Jenkins_Expecter { + return &Jenkins_Expecter{mock: &_m.Mock} +} + // BuildJob provides a mock function with given fields: ctx, name, params func (_m *Jenkins) BuildJob(ctx context.Context, name string, params map[string]string) (int64, error) { ret := _m.Called(ctx, name, params) + if len(ret) == 0 { + panic("no return value specified for BuildJob") + } + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string) (int64, error)); ok { + return rf(ctx, name, params) + } if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string) int64); ok { r0 = rf(ctx, name, params) } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, string, map[string]string) error); ok { r1 = rf(ctx, name, params) } else { @@ -36,11 +51,49 @@ func (_m *Jenkins) BuildJob(ctx context.Context, name string, params map[string] return r0, r1 } +// Jenkins_BuildJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BuildJob' +type Jenkins_BuildJob_Call struct { + *mock.Call +} + +// BuildJob is a helper method to define mock.On call +// - ctx context.Context +// - name string +// - params map[string]string +func (_e *Jenkins_Expecter) BuildJob(ctx interface{}, name interface{}, params interface{}) *Jenkins_BuildJob_Call { + return &Jenkins_BuildJob_Call{Call: _e.mock.On("BuildJob", ctx, name, params)} +} + +func (_c *Jenkins_BuildJob_Call) Run(run func(ctx context.Context, name string, params map[string]string)) *Jenkins_BuildJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(map[string]string)) + }) + return _c +} + +func (_c *Jenkins_BuildJob_Call) Return(_a0 int64, _a1 error) *Jenkins_BuildJob_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Jenkins_BuildJob_Call) RunAndReturn(run func(context.Context, string, map[string]string) (int64, error)) *Jenkins_BuildJob_Call { + _c.Call.Return(run) + return _c +} + // GetBuildFromQueueID provides a mock function with given fields: ctx, job, queueid func (_m *Jenkins) GetBuildFromQueueID(ctx context.Context, job *gojenkins.Job, queueid int64) (*gojenkins.Build, error) { ret := _m.Called(ctx, job, queueid) + if len(ret) == 0 { + panic("no return value specified for GetBuildFromQueueID") + } + var r0 *gojenkins.Build + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *gojenkins.Job, int64) (*gojenkins.Build, error)); ok { + return rf(ctx, job, queueid) + } if rf, ok := ret.Get(0).(func(context.Context, *gojenkins.Job, int64) *gojenkins.Build); ok { r0 = rf(ctx, job, queueid) } else { @@ -49,7 +102,6 @@ func (_m *Jenkins) GetBuildFromQueueID(ctx context.Context, job *gojenkins.Job, } } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, *gojenkins.Job, int64) error); ok { r1 = rf(ctx, job, queueid) } else { @@ -59,10 +111,44 @@ func (_m *Jenkins) GetBuildFromQueueID(ctx context.Context, job *gojenkins.Job, return r0, r1 } +// Jenkins_GetBuildFromQueueID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBuildFromQueueID' +type Jenkins_GetBuildFromQueueID_Call struct { + *mock.Call +} + +// GetBuildFromQueueID is a helper method to define mock.On call +// - ctx context.Context +// - job *gojenkins.Job +// - queueid int64 +func (_e *Jenkins_Expecter) GetBuildFromQueueID(ctx interface{}, job interface{}, queueid interface{}) *Jenkins_GetBuildFromQueueID_Call { + return &Jenkins_GetBuildFromQueueID_Call{Call: _e.mock.On("GetBuildFromQueueID", ctx, job, queueid)} +} + +func (_c *Jenkins_GetBuildFromQueueID_Call) Run(run func(ctx context.Context, job *gojenkins.Job, queueid int64)) *Jenkins_GetBuildFromQueueID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*gojenkins.Job), args[2].(int64)) + }) + return _c +} + +func (_c *Jenkins_GetBuildFromQueueID_Call) Return(_a0 *gojenkins.Build, _a1 error) *Jenkins_GetBuildFromQueueID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Jenkins_GetBuildFromQueueID_Call) RunAndReturn(run func(context.Context, *gojenkins.Job, int64) (*gojenkins.Build, error)) *Jenkins_GetBuildFromQueueID_Call { + _c.Call.Return(run) + return _c +} + // GetJobObj provides a mock function with given fields: ctx, name func (_m *Jenkins) GetJobObj(ctx context.Context, name string) *gojenkins.Job { ret := _m.Called(ctx, name) + if len(ret) == 0 { + panic("no return value specified for GetJobObj") + } + var r0 *gojenkins.Job if rf, ok := ret.Get(0).(func(context.Context, string) *gojenkins.Job); ok { r0 = rf(ctx, name) @@ -74,3 +160,46 @@ func (_m *Jenkins) GetJobObj(ctx context.Context, name string) *gojenkins.Job { return r0 } + +// Jenkins_GetJobObj_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJobObj' +type Jenkins_GetJobObj_Call struct { + *mock.Call +} + +// GetJobObj is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *Jenkins_Expecter) GetJobObj(ctx interface{}, name interface{}) *Jenkins_GetJobObj_Call { + return &Jenkins_GetJobObj_Call{Call: _e.mock.On("GetJobObj", ctx, name)} +} + +func (_c *Jenkins_GetJobObj_Call) Run(run func(ctx context.Context, name string)) *Jenkins_GetJobObj_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *Jenkins_GetJobObj_Call) Return(_a0 *gojenkins.Job) *Jenkins_GetJobObj_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Jenkins_GetJobObj_Call) RunAndReturn(run func(context.Context, string) *gojenkins.Job) *Jenkins_GetJobObj_Call { + _c.Call.Return(run) + return _c +} + +// NewJenkins creates a new instance of Jenkins. 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 NewJenkins(t interface { + mock.TestingT + Cleanup(func()) +}) *Jenkins { + mock := &Jenkins{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/jenkins/mocks/Job.go b/pkg/jenkins/mocks/Job.go index 729c7581c4..89cb925cd8 100644 --- a/pkg/jenkins/mocks/Job.go +++ b/pkg/jenkins/mocks/Job.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.5. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -15,10 +15,22 @@ type Job struct { mock.Mock } +type Job_Expecter struct { + mock *mock.Mock +} + +func (_m *Job) EXPECT() *Job_Expecter { + return &Job_Expecter{mock: &_m.Mock} +} + // GetJob provides a mock function with given fields: func (_m *Job) GetJob() *gojenkins.Job { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetJob") + } + var r0 *gojenkins.Job if rf, ok := ret.Get(0).(func() *gojenkins.Job); ok { r0 = rf() @@ -31,18 +43,52 @@ func (_m *Job) GetJob() *gojenkins.Job { return r0 } +// Job_GetJob_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetJob' +type Job_GetJob_Call struct { + *mock.Call +} + +// GetJob is a helper method to define mock.On call +func (_e *Job_Expecter) GetJob() *Job_GetJob_Call { + return &Job_GetJob_Call{Call: _e.mock.On("GetJob")} +} + +func (_c *Job_GetJob_Call) Run(run func()) *Job_GetJob_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Job_GetJob_Call) Return(_a0 *gojenkins.Job) *Job_GetJob_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Job_GetJob_Call) RunAndReturn(run func() *gojenkins.Job) *Job_GetJob_Call { + _c.Call.Return(run) + return _c +} + // InvokeSimple provides a mock function with given fields: ctx, params func (_m *Job) InvokeSimple(ctx context.Context, params map[string]string) (int64, error) { ret := _m.Called(ctx, params) + if len(ret) == 0 { + panic("no return value specified for InvokeSimple") + } + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, map[string]string) (int64, error)); ok { + return rf(ctx, params) + } if rf, ok := ret.Get(0).(func(context.Context, map[string]string) int64); ok { r0 = rf(ctx, params) } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, map[string]string) error); ok { r1 = rf(ctx, params) } else { @@ -52,18 +98,54 @@ func (_m *Job) InvokeSimple(ctx context.Context, params map[string]string) (int6 return r0, r1 } +// Job_InvokeSimple_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'InvokeSimple' +type Job_InvokeSimple_Call struct { + *mock.Call +} + +// InvokeSimple is a helper method to define mock.On call +// - ctx context.Context +// - params map[string]string +func (_e *Job_Expecter) InvokeSimple(ctx interface{}, params interface{}) *Job_InvokeSimple_Call { + return &Job_InvokeSimple_Call{Call: _e.mock.On("InvokeSimple", ctx, params)} +} + +func (_c *Job_InvokeSimple_Call) Run(run func(ctx context.Context, params map[string]string)) *Job_InvokeSimple_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(map[string]string)) + }) + return _c +} + +func (_c *Job_InvokeSimple_Call) Return(_a0 int64, _a1 error) *Job_InvokeSimple_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Job_InvokeSimple_Call) RunAndReturn(run func(context.Context, map[string]string) (int64, error)) *Job_InvokeSimple_Call { + _c.Call.Return(run) + return _c +} + // Poll provides a mock function with given fields: _a0 func (_m *Job) Poll(_a0 context.Context) (int, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Poll") + } + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (int, error)); ok { + return rf(_a0) + } if rf, ok := ret.Get(0).(func(context.Context) int); ok { r0 = rf(_a0) } else { r0 = ret.Get(0).(int) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(_a0) } else { @@ -72,3 +154,45 @@ func (_m *Job) Poll(_a0 context.Context) (int, error) { return r0, r1 } + +// Job_Poll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Poll' +type Job_Poll_Call struct { + *mock.Call +} + +// Poll is a helper method to define mock.On call +// - _a0 context.Context +func (_e *Job_Expecter) Poll(_a0 interface{}) *Job_Poll_Call { + return &Job_Poll_Call{Call: _e.mock.On("Poll", _a0)} +} + +func (_c *Job_Poll_Call) Run(run func(_a0 context.Context)) *Job_Poll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *Job_Poll_Call) Return(_a0 int, _a1 error) *Job_Poll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Job_Poll_Call) RunAndReturn(run func(context.Context) (int, error)) *Job_Poll_Call { + _c.Call.Return(run) + return _c +} + +// NewJob creates a new instance of Job. 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 NewJob(t interface { + mock.TestingT + Cleanup(func()) +}) *Job { + mock := &Job{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/jenkins/mocks/Task.go b/pkg/jenkins/mocks/Task.go index 9efa542e1a..fa8e01681f 100644 --- a/pkg/jenkins/mocks/Task.go +++ b/pkg/jenkins/mocks/Task.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.7.5. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -15,18 +15,33 @@ type Task struct { mock.Mock } +type Task_Expecter struct { + mock *mock.Mock +} + +func (_m *Task) EXPECT() *Task_Expecter { + return &Task_Expecter{mock: &_m.Mock} +} + // BuildNumber provides a mock function with given fields: func (_m *Task) BuildNumber() (int64, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for BuildNumber") + } + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func() (int64, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -36,10 +51,41 @@ func (_m *Task) BuildNumber() (int64, error) { return r0, r1 } +// Task_BuildNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BuildNumber' +type Task_BuildNumber_Call struct { + *mock.Call +} + +// BuildNumber is a helper method to define mock.On call +func (_e *Task_Expecter) BuildNumber() *Task_BuildNumber_Call { + return &Task_BuildNumber_Call{Call: _e.mock.On("BuildNumber")} +} + +func (_c *Task_BuildNumber_Call) Run(run func()) *Task_BuildNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Task_BuildNumber_Call) Return(_a0 int64, _a1 error) *Task_BuildNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Task_BuildNumber_Call) RunAndReturn(run func() (int64, error)) *Task_BuildNumber_Call { + _c.Call.Return(run) + return _c +} + // HasStarted provides a mock function with given fields: func (_m *Task) HasStarted() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for HasStarted") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -50,18 +96,52 @@ func (_m *Task) HasStarted() bool { return r0 } +// Task_HasStarted_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HasStarted' +type Task_HasStarted_Call struct { + *mock.Call +} + +// HasStarted is a helper method to define mock.On call +func (_e *Task_Expecter) HasStarted() *Task_HasStarted_Call { + return &Task_HasStarted_Call{Call: _e.mock.On("HasStarted")} +} + +func (_c *Task_HasStarted_Call) Run(run func()) *Task_HasStarted_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Task_HasStarted_Call) Return(_a0 bool) *Task_HasStarted_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Task_HasStarted_Call) RunAndReturn(run func() bool) *Task_HasStarted_Call { + _c.Call.Return(run) + return _c +} + // Poll provides a mock function with given fields: _a0 func (_m *Task) Poll(_a0 context.Context) (int, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Poll") + } + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (int, error)); ok { + return rf(_a0) + } if rf, ok := ret.Get(0).(func(context.Context) int); ok { r0 = rf(_a0) } else { r0 = ret.Get(0).(int) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context) error); ok { r1 = rf(_a0) } else { @@ -71,18 +151,53 @@ func (_m *Task) Poll(_a0 context.Context) (int, error) { return r0, r1 } +// Task_Poll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Poll' +type Task_Poll_Call struct { + *mock.Call +} + +// Poll is a helper method to define mock.On call +// - _a0 context.Context +func (_e *Task_Expecter) Poll(_a0 interface{}) *Task_Poll_Call { + return &Task_Poll_Call{Call: _e.mock.On("Poll", _a0)} +} + +func (_c *Task_Poll_Call) Run(run func(_a0 context.Context)) *Task_Poll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *Task_Poll_Call) Return(_a0 int, _a1 error) *Task_Poll_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Task_Poll_Call) RunAndReturn(run func(context.Context) (int, error)) *Task_Poll_Call { + _c.Call.Return(run) + return _c +} + // WaitToStart provides a mock function with given fields: ctx, pollInterval func (_m *Task) WaitToStart(ctx context.Context, pollInterval time.Duration) (int64, error) { ret := _m.Called(ctx, pollInterval) + if len(ret) == 0 { + panic("no return value specified for WaitToStart") + } + var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, time.Duration) (int64, error)); ok { + return rf(ctx, pollInterval) + } if rf, ok := ret.Get(0).(func(context.Context, time.Duration) int64); ok { r0 = rf(ctx, pollInterval) } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func(context.Context, time.Duration) error); ok { r1 = rf(ctx, pollInterval) } else { @@ -91,3 +206,46 @@ func (_m *Task) WaitToStart(ctx context.Context, pollInterval time.Duration) (in return r0, r1 } + +// Task_WaitToStart_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitToStart' +type Task_WaitToStart_Call struct { + *mock.Call +} + +// WaitToStart is a helper method to define mock.On call +// - ctx context.Context +// - pollInterval time.Duration +func (_e *Task_Expecter) WaitToStart(ctx interface{}, pollInterval interface{}) *Task_WaitToStart_Call { + return &Task_WaitToStart_Call{Call: _e.mock.On("WaitToStart", ctx, pollInterval)} +} + +func (_c *Task_WaitToStart_Call) Run(run func(ctx context.Context, pollInterval time.Duration)) *Task_WaitToStart_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(time.Duration)) + }) + return _c +} + +func (_c *Task_WaitToStart_Call) Return(_a0 int64, _a1 error) *Task_WaitToStart_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Task_WaitToStart_Call) RunAndReturn(run func(context.Context, time.Duration) (int64, error)) *Task_WaitToStart_Call { + _c.Call.Return(run) + return _c +} + +// NewTask creates a new instance of Task. 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 NewTask(t interface { + mock.TestingT + Cleanup(func()) +}) *Task { + mock := &Task{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/jenkins/task.go b/pkg/jenkins/task.go index deaa5ef51e..a796e198c3 100644 --- a/pkg/jenkins/task.go +++ b/pkg/jenkins/task.go @@ -9,7 +9,6 @@ import ( ) // Task is an interface to abstract gojenkins.Task. -// mock generated with: mockery --name Task --dir pkg/jenkins --output pkg/jenkins/mocks type Task interface { Poll(context.Context) (int, error) BuildNumber() (int64, error) diff --git a/pkg/kubernetes/mocks/HelmExecutor.go b/pkg/kubernetes/mocks/HelmExecutor.go index 4232366115..38cb8de580 100644 --- a/pkg/kubernetes/mocks/HelmExecutor.go +++ b/pkg/kubernetes/mocks/HelmExecutor.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -9,10 +9,22 @@ type HelmExecutor struct { mock.Mock } +type HelmExecutor_Expecter struct { + mock *mock.Mock +} + +func (_m *HelmExecutor) EXPECT() *HelmExecutor_Expecter { + return &HelmExecutor_Expecter{mock: &_m.Mock} +} + // RunHelmDependency provides a mock function with given fields: func (_m *HelmExecutor) RunHelmDependency() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmDependency") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -23,10 +35,41 @@ func (_m *HelmExecutor) RunHelmDependency() error { return r0 } +// HelmExecutor_RunHelmDependency_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmDependency' +type HelmExecutor_RunHelmDependency_Call struct { + *mock.Call +} + +// RunHelmDependency is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmDependency() *HelmExecutor_RunHelmDependency_Call { + return &HelmExecutor_RunHelmDependency_Call{Call: _e.mock.On("RunHelmDependency")} +} + +func (_c *HelmExecutor_RunHelmDependency_Call) Run(run func()) *HelmExecutor_RunHelmDependency_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmDependency_Call) Return(_a0 error) *HelmExecutor_RunHelmDependency_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HelmExecutor_RunHelmDependency_Call) RunAndReturn(run func() error) *HelmExecutor_RunHelmDependency_Call { + _c.Call.Return(run) + return _c +} + // RunHelmInstall provides a mock function with given fields: func (_m *HelmExecutor) RunHelmInstall() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmInstall") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -37,10 +80,41 @@ func (_m *HelmExecutor) RunHelmInstall() error { return r0 } +// HelmExecutor_RunHelmInstall_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmInstall' +type HelmExecutor_RunHelmInstall_Call struct { + *mock.Call +} + +// RunHelmInstall is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmInstall() *HelmExecutor_RunHelmInstall_Call { + return &HelmExecutor_RunHelmInstall_Call{Call: _e.mock.On("RunHelmInstall")} +} + +func (_c *HelmExecutor_RunHelmInstall_Call) Run(run func()) *HelmExecutor_RunHelmInstall_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmInstall_Call) Return(_a0 error) *HelmExecutor_RunHelmInstall_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HelmExecutor_RunHelmInstall_Call) RunAndReturn(run func() error) *HelmExecutor_RunHelmInstall_Call { + _c.Call.Return(run) + return _c +} + // RunHelmLint provides a mock function with given fields: func (_m *HelmExecutor) RunHelmLint() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmLint") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -51,18 +125,52 @@ func (_m *HelmExecutor) RunHelmLint() error { return r0 } +// HelmExecutor_RunHelmLint_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmLint' +type HelmExecutor_RunHelmLint_Call struct { + *mock.Call +} + +// RunHelmLint is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmLint() *HelmExecutor_RunHelmLint_Call { + return &HelmExecutor_RunHelmLint_Call{Call: _e.mock.On("RunHelmLint")} +} + +func (_c *HelmExecutor_RunHelmLint_Call) Run(run func()) *HelmExecutor_RunHelmLint_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmLint_Call) Return(_a0 error) *HelmExecutor_RunHelmLint_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HelmExecutor_RunHelmLint_Call) RunAndReturn(run func() error) *HelmExecutor_RunHelmLint_Call { + _c.Call.Return(run) + return _c +} + // RunHelmPublish provides a mock function with given fields: func (_m *HelmExecutor) RunHelmPublish() (string, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmPublish") + } + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func() (string, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -72,10 +180,41 @@ func (_m *HelmExecutor) RunHelmPublish() (string, error) { return r0, r1 } +// HelmExecutor_RunHelmPublish_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmPublish' +type HelmExecutor_RunHelmPublish_Call struct { + *mock.Call +} + +// RunHelmPublish is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmPublish() *HelmExecutor_RunHelmPublish_Call { + return &HelmExecutor_RunHelmPublish_Call{Call: _e.mock.On("RunHelmPublish")} +} + +func (_c *HelmExecutor_RunHelmPublish_Call) Run(run func()) *HelmExecutor_RunHelmPublish_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmPublish_Call) Return(_a0 string, _a1 error) *HelmExecutor_RunHelmPublish_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *HelmExecutor_RunHelmPublish_Call) RunAndReturn(run func() (string, error)) *HelmExecutor_RunHelmPublish_Call { + _c.Call.Return(run) + return _c +} + // RunHelmTest provides a mock function with given fields: func (_m *HelmExecutor) RunHelmTest() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmTest") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -86,10 +225,41 @@ func (_m *HelmExecutor) RunHelmTest() error { return r0 } +// HelmExecutor_RunHelmTest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmTest' +type HelmExecutor_RunHelmTest_Call struct { + *mock.Call +} + +// RunHelmTest is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmTest() *HelmExecutor_RunHelmTest_Call { + return &HelmExecutor_RunHelmTest_Call{Call: _e.mock.On("RunHelmTest")} +} + +func (_c *HelmExecutor_RunHelmTest_Call) Run(run func()) *HelmExecutor_RunHelmTest_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmTest_Call) Return(_a0 error) *HelmExecutor_RunHelmTest_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HelmExecutor_RunHelmTest_Call) RunAndReturn(run func() error) *HelmExecutor_RunHelmTest_Call { + _c.Call.Return(run) + return _c +} + // RunHelmUninstall provides a mock function with given fields: func (_m *HelmExecutor) RunHelmUninstall() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmUninstall") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -100,10 +270,41 @@ func (_m *HelmExecutor) RunHelmUninstall() error { return r0 } +// HelmExecutor_RunHelmUninstall_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmUninstall' +type HelmExecutor_RunHelmUninstall_Call struct { + *mock.Call +} + +// RunHelmUninstall is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmUninstall() *HelmExecutor_RunHelmUninstall_Call { + return &HelmExecutor_RunHelmUninstall_Call{Call: _e.mock.On("RunHelmUninstall")} +} + +func (_c *HelmExecutor_RunHelmUninstall_Call) Run(run func()) *HelmExecutor_RunHelmUninstall_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmUninstall_Call) Return(_a0 error) *HelmExecutor_RunHelmUninstall_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HelmExecutor_RunHelmUninstall_Call) RunAndReturn(run func() error) *HelmExecutor_RunHelmUninstall_Call { + _c.Call.Return(run) + return _c +} + // RunHelmUpgrade provides a mock function with given fields: func (_m *HelmExecutor) RunHelmUpgrade() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for RunHelmUpgrade") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -114,13 +315,39 @@ func (_m *HelmExecutor) RunHelmUpgrade() error { return r0 } -type mockConstructorTestingTNewHelmExecutor interface { - mock.TestingT - Cleanup(func()) +// HelmExecutor_RunHelmUpgrade_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RunHelmUpgrade' +type HelmExecutor_RunHelmUpgrade_Call struct { + *mock.Call +} + +// RunHelmUpgrade is a helper method to define mock.On call +func (_e *HelmExecutor_Expecter) RunHelmUpgrade() *HelmExecutor_RunHelmUpgrade_Call { + return &HelmExecutor_RunHelmUpgrade_Call{Call: _e.mock.On("RunHelmUpgrade")} +} + +func (_c *HelmExecutor_RunHelmUpgrade_Call) Run(run func()) *HelmExecutor_RunHelmUpgrade_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *HelmExecutor_RunHelmUpgrade_Call) Return(_a0 error) *HelmExecutor_RunHelmUpgrade_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *HelmExecutor_RunHelmUpgrade_Call) RunAndReturn(run func() error) *HelmExecutor_RunHelmUpgrade_Call { + _c.Call.Return(run) + return _c } // NewHelmExecutor creates a new instance of HelmExecutor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewHelmExecutor(t mockConstructorTestingTNewHelmExecutor) *HelmExecutor { +// The first argument is typically a *testing.T value. +func NewHelmExecutor(t interface { + mock.TestingT + Cleanup(func()) +}) *HelmExecutor { mock := &HelmExecutor{} mock.Mock.Test(t)