MCPcopy Index your code
hub / github.com/cli/cli / TestHandleHTTPError_GraphQL502

Function TestHandleHTTPError_GraphQL502

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

Source from the content-addressed store, hash-verified

139}
140
141func TestHandleHTTPError_GraphQL502(t *testing.T) {
142 req, err := http.NewRequest("GET", "https://api.github.com/user", nil)
143 if err != nil {
144 t.Fatal(err)
145 }
146 resp := &http.Response{
147 Request: req,
148 StatusCode: 502,
149 Body: io.NopCloser(bytes.NewBufferString(`{ "data": null, "errors": [{ "message": "Something went wrong" }] }`)),
150 Header: map[string][]string{"Content-Type": {"application/json"}},
151 }
152 err = HandleHTTPError(resp)
153 if err == nil || err.Error() != "HTTP 502: Something went wrong (https://api.github.com/user)" {
154 t.Errorf("got error: %v", err)
155 }
156}
157
158func TestHTTPError_ScopesSuggestion(t *testing.T) {
159 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