fakeGet prints the status and body of a GET. It fails for an error or a status of 300 or more.
(client *http.Client, url string)
| 251 | // fakeGet prints the status and body of a GET. It fails for an error or a |
| 252 | // status of 300 or more. |
| 253 | func fakeGet(client *http.Client, url string) int { |
| 254 | resp, err := client.Get(url) |
| 255 | if err != nil { |
| 256 | fmt.Fprintln(os.Stderr, err) |
| 257 | return 1 |
| 258 | } |
| 259 | defer resp.Body.Close() |
| 260 | body, _ := io.ReadAll(resp.Body) |
| 261 | fmt.Printf("%d %s\n", resp.StatusCode, strings.TrimSpace(string(body))) |
| 262 | if resp.StatusCode >= 300 { |
| 263 | return 1 |
| 264 | } |
| 265 | return 0 |
| 266 | } |
| 267 | |
| 268 | // writeFakeGH writes a wrapper that runs the test binary as gh. |
| 269 | func writeFakeGH(t *testing.T, variant string) string { |