mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
chore(jenkins): expose artifacts save method (#2426)
* fix code smell * expose artifact.Save function * regenerate mock file
This commit is contained in:
parent
26af83b1fc
commit
860b28884c
@ -5,7 +5,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Artifact is an interface to abstract gojenkins.Artifact.
|
// Artifact is an interface to abstract gojenkins.Artifact.
|
||||||
|
// mock generated with: mockery --name Artifact --dir pkg/jenkins --output pkg/jenkins/mocks
|
||||||
type Artifact interface {
|
type Artifact interface {
|
||||||
|
Save(path string) (bool, error)
|
||||||
SaveToDir(dir string) (bool, error)
|
SaveToDir(dir string) (bool, error)
|
||||||
GetData() ([]byte, error)
|
GetData() ([]byte, error)
|
||||||
FileName() string
|
FileName() string
|
||||||
@ -16,6 +18,11 @@ type ArtifactImpl struct {
|
|||||||
artifact gojenkins.Artifact
|
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.
|
// SaveToDir refers to the gojenkins.Artifact.SaveToDir function.
|
||||||
func (a *ArtifactImpl) SaveToDir(dir string) (bool, error) {
|
func (a *ArtifactImpl) SaveToDir(dir string) (bool, error) {
|
||||||
return a.artifact.SaveToDir(dir)
|
return a.artifact.SaveToDir(dir)
|
||||||
|
@ -34,8 +34,8 @@ func TestFetchBuildArtifact(t *testing.T) {
|
|||||||
build.On("IsRunning").Return(false)
|
build.On("IsRunning").Return(false)
|
||||||
build.On("GetArtifacts").Return(
|
build.On("GetArtifacts").Return(
|
||||||
[]gojenkins.Artifact{
|
[]gojenkins.Artifact{
|
||||||
gojenkins.Artifact{FileName: mock.Anything},
|
{FileName: mock.Anything},
|
||||||
gojenkins.Artifact{FileName: fileName},
|
{FileName: fileName},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
// test
|
// test
|
||||||
@ -70,7 +70,7 @@ func TestFetchBuildArtifact(t *testing.T) {
|
|||||||
// init
|
// init
|
||||||
build := &mocks.Build{}
|
build := &mocks.Build{}
|
||||||
build.On("IsRunning").Return(false)
|
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
|
// test
|
||||||
_, err := FetchBuildArtifact(build, fileName)
|
_, err := FetchBuildArtifact(build, fileName)
|
||||||
// asserts
|
// asserts
|
||||||
|
@ -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
|
package mocks
|
||||||
|
|
||||||
@ -46,6 +46,27 @@ func (_m *Artifact) GetData() ([]byte, error) {
|
|||||||
return r0, r1
|
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
|
// SaveToDir provides a mock function with given fields: dir
|
||||||
func (_m *Artifact) SaveToDir(dir string) (bool, error) {
|
func (_m *Artifact) SaveToDir(dir string) (bool, error) {
|
||||||
ret := _m.Called(dir)
|
ret := _m.Called(dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user