| 136 | } |
| 137 | |
| 138 | func TestRepoKeysHTTPError(t *testing.T) { |
| 139 | reg := &httpmock.Registry{} |
| 140 | defer reg.Verify(t) |
| 141 | |
| 142 | reg.Register( |
| 143 | httpmock.REST("GET", "repos/OWNER/REPO/keys"), |
| 144 | httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`), |
| 145 | ) |
| 146 | |
| 147 | _, err := repoKeys( |
| 148 | &http.Client{Transport: reg}, |
| 149 | ghrepo.New("OWNER", "REPO"), |
| 150 | ) |
| 151 | |
| 152 | var httpErr api.HTTPError |
| 153 | require.ErrorAs(t, err, &httpErr) |
| 154 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 155 | assert.Contains(t, err.Error(), "HTTP 404") |
| 156 | } |