(t *testing.T)
| 140 | } |
| 141 | |
| 142 | func TestRESTWithNextError(t *testing.T) { |
| 143 | reg := &httpmock.Registry{} |
| 144 | defer reg.Verify(t) |
| 145 | client := newTestClient(reg) |
| 146 | |
| 147 | reg.Register(httpmock.MatchAny, func(req *http.Request) (*http.Response, error) { |
| 148 | return &http.Response{ |
| 149 | Request: req, |
| 150 | StatusCode: http.StatusNotFound, |
| 151 | Body: io.NopCloser(bytes.NewBufferString(`{"message": "Not Found"}`)), |
| 152 | Header: http.Header{ |
| 153 | "Content-Type": {"application/json"}, |
| 154 | "X-Accepted-Oauth-Scopes": {"repo"}, |
| 155 | "X-Oauth-Scopes": {"read:user"}, |
| 156 | }, |
| 157 | }, nil |
| 158 | }) |
| 159 | |
| 160 | _, err := client.RESTWithNext("github.com", http.MethodGet, "repos/owner/repo/items", nil, nil) |
| 161 | |
| 162 | var httpErr HTTPError |
| 163 | require.ErrorAs(t, err, &httpErr) |
| 164 | assert.Equal(t, http.StatusNotFound, httpErr.StatusCode) |
| 165 | assert.Contains(t, err.Error(), "HTTP 404") |
| 166 | assert.Equal(t, `This API operation needs the "repo" scope. To request it, run: gh auth refresh -h github.com -s repo`, httpErr.ScopesSuggestion()) |
| 167 | } |
| 168 | |
| 169 | func TestRESTAndRESTWithNextErrorTypeParity(t *testing.T) { |
| 170 | reg := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected