(t *testing.T)
| 32 | } |
| 33 | |
| 34 | func Test_userKeysHTTPError(t *testing.T) { |
| 35 | reg := &httpmock.Registry{} |
| 36 | defer reg.Verify(t) |
| 37 | reg.Register( |
| 38 | httpmock.QueryMatcher("GET", "user/gpg_keys", url.Values{"per_page": []string{"100"}}), |
| 39 | httpmock.WithHeader( |
| 40 | httpmock.StatusStringResponse(http.StatusInternalServerError, `{"message":"Internal Server Error"}`), |
| 41 | "Content-Type", "application/json", |
| 42 | ), |
| 43 | ) |
| 44 | |
| 45 | keys, err := userKeys(&http.Client{Transport: reg}, "github.com", "") |
| 46 | |
| 47 | assert.Nil(t, keys) |
| 48 | var httpErr api.HTTPError |
| 49 | require.ErrorAs(t, err, &httpErr) |
| 50 | assert.Equal(t, http.StatusInternalServerError, httpErr.StatusCode) |
| 51 | assert.Contains(t, err.Error(), "HTTP 500") |
| 52 | assert.EqualError(t, err, "HTTP 500: Internal Server Error (https://api.github.com/user/gpg_keys?per_page=100)") |
| 53 | } |
| 54 | |
| 55 | func Test_userKeysForUser(t *testing.T) { |
| 56 | reg := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected