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

Function TestRequestWithHeader

api/request_test.go:70–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestRequestWithHeader(t *testing.T) {
71 reg := &httpmock.Registry{}
72 defer reg.Verify(t)
73 client := newTestClient(reg)
74
75 reg.Register(httpmock.MatchAny, httpmock.StatusStringResponse(200, "{}"))
76
77 resp, err := client.Request("github.com", http.MethodGet, "repos/OWNER/REPO", nil,
78 WithHeader("Accept", "application/vnd.github.raw"))
79 require.NoError(t, err)
80 defer resp.Body.Close()
81
82 assert.Equal(t, "application/vnd.github.raw", reg.Requests[0].Header.Get("Accept"))
83}
84
85// The transport supplies default headers of its own, so a per-request header is only useful if it
86// takes precedence over them.

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
RegisterMethod · 0.95
StatusStringResponseFunction · 0.92
newTestClientFunction · 0.85
RequestMethod · 0.80
EqualMethod · 0.80
WithHeaderFunction · 0.70
CloseMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected