mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
fix(jenkins): correct interface (#2862)
* update mock * update signarture * add test case
This commit is contained in:
parent
62836a64e7
commit
e24b38da24
@ -12,7 +12,7 @@ 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 {
|
||||
BuildJob(ctx context.Context, name string, options ...interface{}) (int64, error)
|
||||
BuildJob(ctx context.Context, name string, params map[string]string) (int64, error)
|
||||
GetBuildFromQueueID(ctx context.Context, queueid int64) (*gojenkins.Build, error)
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,11 @@ import (
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
func TestInterfaceCompatibility(t *testing.T) {
|
||||
var _ Jenkins = new(gojenkins.Jenkins)
|
||||
var _ Build = new(gojenkins.Build)
|
||||
}
|
||||
|
||||
func TestTriggerJob(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
jobName := "ContinuousDelivery/piper-library"
|
||||
|
@ -15,23 +15,20 @@ type Jenkins struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// BuildJob provides a mock function with given fields: ctx, name, options
|
||||
func (_m *Jenkins) BuildJob(ctx context.Context, name string, options ...interface{}) (int64, error) {
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, name)
|
||||
_ca = append(_ca, options...)
|
||||
ret := _m.Called(_ca...)
|
||||
// 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)
|
||||
|
||||
var r0 int64
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, ...interface{}) int64); ok {
|
||||
r0 = rf(ctx, name, options...)
|
||||
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, ...interface{}) error); ok {
|
||||
r1 = rf(ctx, name, options...)
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, map[string]string) error); ok {
|
||||
r1 = rf(ctx, name, params)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user