(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func Test_getGPGKeysHTTPError(t *testing.T) { |
| 43 | reg := &httpmock.Registry{} |
| 44 | defer reg.Verify(t) |
| 45 | reg.Register( |
| 46 | httpmock.QueryMatcher("GET", "user/gpg_keys", url.Values{"per_page": []string{"100"}}), |
| 47 | httpmock.WithHeader( |
| 48 | httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`), |
| 49 | "Content-Type", "application/json", |
| 50 | ), |
| 51 | ) |
| 52 | |
| 53 | keys, err := getGPGKeys(&http.Client{Transport: reg}, "github.com") |
| 54 | |
| 55 | assert.Nil(t, keys) |
| 56 | var httpErr api.HTTPError |
| 57 | require.ErrorAs(t, err, &httpErr) |
| 58 | assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode) |
| 59 | assert.Contains(t, err.Error(), "HTTP 500") |
| 60 | assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys?per_page=100)") |
| 61 | } |
| 62 | |
| 63 | func TestNewCmdDelete(t *testing.T) { |
| 64 | tests := []struct { |
nothing calls this directly
no test coverage detected