2018-03-26 13:32:04 +00:00
|
|
|
package marathon
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"github.com/gambol99/go-marathon"
|
|
|
|
"github.com/stretchr/testify/mock"
|
2020-09-16 13:46:04 +00:00
|
|
|
"github.com/traefik/traefik/v2/pkg/provider/marathon/mocks"
|
2018-03-26 13:32:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type fakeClient struct {
|
|
|
|
mocks.Marathon
|
|
|
|
}
|
|
|
|
|
|
|
|
func newFakeClient(applicationsError bool, applications marathon.Applications) *fakeClient {
|
|
|
|
// create an instance of our test object
|
|
|
|
fakeClient := new(fakeClient)
|
|
|
|
if applicationsError {
|
|
|
|
fakeClient.On("Applications", mock.Anything).Return(nil, errors.New("fake Marathon server error"))
|
|
|
|
} else {
|
|
|
|
fakeClient.On("Applications", mock.Anything).Return(&applications, nil)
|
|
|
|
}
|
|
|
|
return fakeClient
|
|
|
|
}
|