MCPcopy Create free account
hub / github.com/cli/cli / TestRequestError

Function TestRequestError

api/request_test.go:169–184  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestRequestError(t *testing.T) {
170 reg := &httpmock.Registry{}
171 defer reg.Verify(t)
172 client := newTestClient(reg)
173
174 reg.Register(httpmock.MatchAny, httpmock.StatusJSONResponse(404, map[string]any{
175 "message": "Not Found",
176 }))
177
178 resp, err := client.Request("github.com", http.MethodGet, "repos/OWNER/REPO", nil)
179 assert.Nil(t, resp)
180
181 var httpErr HTTPError
182 require.ErrorAs(t, err, &httpErr)
183 assert.Equal(t, 404, httpErr.StatusCode)
184}
185
186func TestRequestErrorPreservesScopesSuggestion(t *testing.T) {
187 reg := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 6

VerifyMethod · 0.95
RegisterMethod · 0.95
StatusJSONResponseFunction · 0.92
newTestClientFunction · 0.85
RequestMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected