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

Function fakeGet

script/ghmock/run_test.go:253–266  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

251// fakeGet prints the status and body of a GET. It fails for an error or a
252// status of 300 or more.
253func 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.
269func writeFakeGH(t *testing.T, variant string) string {

Callers 1

fakeGHFunction · 0.85

Calls 3

GetMethod · 0.65
CloseMethod · 0.65
PrintfMethod · 0.65

Tested by

no test coverage detected