(t *testing.T)
| 234 | } |
| 235 | |
| 236 | func 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 | |
| 253 | func TestHTTPError_ScopesSuggestion(t *testing.T) { |
| 254 | makeResponse := func(s int, u, haveScopes, needScopes string) *http.Response { |
nothing calls this directly
no test coverage detected