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

Function TestHandleHTTPError_GraphQL502

api/client_test.go:236–251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

234}
235
236func TestHandleHTTPError_GraphQL502(t *testing.T) {
237 req, err := http.NewRequest("GET", "https://api.github.com/user", nil)
238 if err != nil {
239 t.Fatal(err)
240 }
241 resp := &http.Response{
242 Request: req,
243 StatusCode: 502,
244 Body: io.NopCloser(bytes.NewBufferString(`{ "data": null, "errors": [{ "message": "Something went wrong" }] }`)),
245 Header: map[string][]string{"Content-Type": {"application/json"}},
246 }
247 err = HandleHTTPError(resp)
248 if err == nil || err.Error() != "HTTP 502: Something went wrong (https://api.github.com/user)" {
249 t.Errorf("got error: %v", err)
250 }
251}
252
253func TestHTTPError_ScopesSuggestion(t *testing.T) {
254 makeResponse := func(s int, u, haveScopes, needScopes string) *http.Response {

Callers

nothing calls this directly

Calls 3

HandleHTTPErrorFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected