| 11 | ) |
| 12 | |
| 13 | func TestUserKeysHTTPError(t *testing.T) { |
| 14 | reg := &httpmock.Registry{} |
| 15 | defer reg.Verify(t) |
| 16 | reg.Register( |
| 17 | httpmock.REST("GET", "user/keys"), |
| 18 | httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`), |
| 19 | ) |
| 20 | |
| 21 | keys, err := UserKeys(&http.Client{Transport: reg}, "github.com", "") |
| 22 | |
| 23 | assert.Nil(t, keys) |
| 24 | var httpErr api.HTTPError |
| 25 | require.ErrorAs(t, err, &httpErr) |
| 26 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 27 | assert.Contains(t, err.Error(), "HTTP 404") |
| 28 | } |