Skip to content

Commit

Permalink
SCALRCORE-18723 Fix Provider to handle 404 error
Browse files Browse the repository at this point in the history
  • Loading branch information
ablik committed Sep 2, 2021
1 parent 89c9dd2 commit 9ac71df
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions scalr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,28 @@ func TestClient_retryHTTPCheck(t *testing.T) {
}
}

func TestClient_notFoundErrorWithoutMessage(t *testing.T) {
resp := &http.Response{
StatusCode: 404,
Body: ioutil.NopCloser(bytes.NewBufferString("test boody")),
func TestClient_errorWithoutMessage(t *testing.T) {
cases := map[string]struct {
resp *http.Response
err error
}{
"404-not-found-error": {
resp: &http.Response{StatusCode: 404, Body: ioutil.NopCloser(bytes.NewBufferString("test body"))},
err: ErrResourceNotFound{},
},
"500-server-error": {
resp: &http.Response{StatusCode: 500, Body: ioutil.NopCloser(bytes.NewBufferString("test body"))},
err: errors.New(""),
},
}
err := checkResponseCode(resp)

if err != nil {
assert.Error(t, err)
assert.Equal(t, err, ErrResourceNotFound{})
for _, tc := range cases {
err := checkResponseCode(tc.resp)

if err != nil {
assert.Error(t, err)
assert.Equal(t, err, tc.err)
}
}
}

Expand Down

0 comments on commit 9ac71df

Please sign in to comment.