Skip to content

Commit

Permalink
update client_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
eiixy committed Sep 23, 2024
1 parent 17c79a0 commit 9822ff0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func (c *Client) handleErrorResp(resp *http.Response) error {
if !strings.HasPrefix(resp.Header.Get("Content-Type"), "application/json") {
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
return fmt.Errorf("error, reading response body: %s", err)

Check failure on line 291 in client.go

View workflow job for this annotation

GitHub Actions / Sanity check

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
return fmt.Errorf("error, status code: %d, status: %s, body: %s", resp.StatusCode, resp.Status, body)
}
Expand Down
7 changes: 7 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ func TestHandleErrorResp(t *testing.T) {
</body>
</html>`,
},
{
name: "errorReader",
httpCode: http.StatusRequestEntityTooLarge,
contentType: "text/html",
body: &errorReader{err: errors.New("errorReader")},
expected: "error, reading response body: errorReader",
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 9822ff0

Please sign in to comment.