Skip to content

Commit

Permalink
Udates tests for basic auth support
Browse files Browse the repository at this point in the history
  • Loading branch information
ckaznocha committed Aug 23, 2016
1 parent 071997d commit 087c6e5
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/marathon-resource/marathon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func Test_marathon_handleReq(t *testing.T) {
u, _ = url.Parse("http://foo.bar/")
)
defer ctrl.Finish()
mockClient.EXPECT().Do(gomock.Any()).Times(1).Return(
mockClient.EXPECT().Do(gomock.Any()).Times(2).Return(
&http.Response{
StatusCode: http.StatusOK,
Body: ioutil.NopCloser(strings.NewReader(`{"foo":"bar"}`)),
Expand All @@ -92,6 +92,7 @@ func Test_marathon_handleReq(t *testing.T) {
type fields struct {
client doer
url *url.URL
auth *authCreds
}
type args struct {
method string
Expand All @@ -108,7 +109,19 @@ func Test_marathon_handleReq(t *testing.T) {
}{
{
"No body",
fields{mockClient, u},
fields{mockClient, u, nil},
args{
http.MethodGet,
"/",
nil,
http.StatusOK,
&map[string]string{},
},
false,
},
{
"With Auth",
fields{mockClient, u, &authCreds{"foo", "bar"}},
args{
http.MethodGet,
"/",
Expand All @@ -120,7 +133,7 @@ func Test_marathon_handleReq(t *testing.T) {
},
{
"Bad Status code",
fields{mockClient, u},
fields{mockClient, u, nil},
args{
http.MethodGet,
"/",
Expand All @@ -132,7 +145,7 @@ func Test_marathon_handleReq(t *testing.T) {
},
{
"Error",
fields{mockClient, u},
fields{mockClient, u, nil},
args{
http.MethodGet,
"/",
Expand All @@ -147,6 +160,7 @@ func Test_marathon_handleReq(t *testing.T) {
m := &marathon{
client: tt.fields.client,
url: tt.fields.url,
auth: tt.fields.auth,
}
if err := m.handleReq(tt.args.method, tt.args.path, tt.args.payload, tt.args.wantCode, tt.args.resObj); (err != nil) != tt.wantErr {
t.Errorf("%q. marathon.handleReq(%v, %v, %v, %v, %v) error = %v, wantErr %v", tt.name, tt.args.method, tt.args.path, tt.args.payload, tt.args.wantCode, tt.args.resObj, err, tt.wantErr)
Expand Down

0 comments on commit 087c6e5

Please sign in to comment.