(t *testing.T)
| 20 | ) |
| 21 | |
| 22 | func Test_deleteGPGKeyHTTPError(t *testing.T) { |
| 23 | reg := &httpmock.Registry{} |
| 24 | defer reg.Verify(t) |
| 25 | reg.Register( |
| 26 | httpmock.REST("DELETE", "user/gpg_keys/123"), |
| 27 | httpmock.WithHeader( |
| 28 | httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`), |
| 29 | "Content-Type", "application/json", |
| 30 | ), |
| 31 | ) |
| 32 | |
| 33 | err := deleteGPGKey(&http.Client{Transport: reg}, "github.com", "123") |
| 34 | |
| 35 | var httpErr api.HTTPError |
| 36 | require.ErrorAs(t, err, &httpErr) |
| 37 | assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode) |
| 38 | assert.Contains(t, err.Error(), "HTTP 500") |
| 39 | assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys/123)") |
| 40 | } |
| 41 | |
| 42 | func Test_getGPGKeysHTTPError(t *testing.T) { |
| 43 | reg := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected