diff --git a/pkg/jenkins/artifact.go b/pkg/jenkins/artifact.go index 8a41f528c..688083461 100644 --- a/pkg/jenkins/artifact.go +++ b/pkg/jenkins/artifact.go @@ -5,7 +5,9 @@ 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(path string) (bool, error) SaveToDir(dir string) (bool, error) GetData() ([]byte, error) FileName() string @@ -16,6 +18,11 @@ type ArtifactImpl struct { artifact gojenkins.Artifact } +// Save refers to the gojenkins.Artifact.Save function. +func (a *ArtifactImpl) Save(path string) (bool, error) { + return a.artifact.Save(path) +} + // SaveToDir refers to the gojenkins.Artifact.SaveToDir function. func (a *ArtifactImpl) SaveToDir(dir string) (bool, error) { return a.artifact.SaveToDir(dir) diff --git a/pkg/jenkins/build_test.go b/pkg/jenkins/build_test.go index fba0eb5ea..e9fc54681 100644 --- a/pkg/jenkins/build_test.go +++ b/pkg/jenkins/build_test.go @@ -34,8 +34,8 @@ func TestFetchBuildArtifact(t *testing.T) { build.On("IsRunning").Return(false) build.On("GetArtifacts").Return( []gojenkins.Artifact{ - gojenkins.Artifact{FileName: mock.Anything}, - gojenkins.Artifact{FileName: fileName}, + {FileName: mock.Anything}, + {FileName: fileName}, }, ) // test @@ -70,7 +70,7 @@ func TestFetchBuildArtifact(t *testing.T) { // init build := &mocks.Build{} build.On("IsRunning").Return(false) - build.On("GetArtifacts").Return([]gojenkins.Artifact{gojenkins.Artifact{FileName: mock.Anything}}) + build.On("GetArtifacts").Return([]gojenkins.Artifact{{FileName: mock.Anything}}) // test _, err := FetchBuildArtifact(build, fileName) // asserts diff --git a/pkg/jenkins/mocks/Artifact.go b/pkg/jenkins/mocks/Artifact.go index 69b9018d8..c3981d004 100644 --- a/pkg/jenkins/mocks/Artifact.go +++ b/pkg/jenkins/mocks/Artifact.go @@ -1,4 +1,4 @@ -// Code generated by mockery v1.0.0. DO NOT EDIT. +// Code generated by mockery v2.0.0-alpha.13. DO NOT EDIT. package mocks @@ -46,6 +46,27 @@ func (_m *Artifact) GetData() ([]byte, error) { return r0, r1 } +// Save provides a mock function with given fields: path +func (_m *Artifact) Save(path string) (bool, error) { + ret := _m.Called(path) + + var r0 bool + if rf, ok := ret.Get(0).(func(string) bool); ok { + r0 = rf(path) + } else { + r0 = ret.Get(0).(bool) + } + + var r1 error + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(path) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // SaveToDir provides a mock function with given fields: dir func (_m *Artifact) SaveToDir(dir string) (bool, error) { ret := _m.Called(dir)