(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func 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 | |
| 158 | func TestHTTPError_ScopesSuggestion(t *testing.T) { |
| 159 | makeResponse := func(s int, u, haveScopes, needScopes string) *http.Response { |
nothing calls this directly
no test coverage detected