The transport supplies default headers of its own, so a per-request header is only useful if it takes precedence over them.
(t *testing.T)
| 85 | // The transport supplies default headers of its own, so a per-request header is only useful if it |
| 86 | // takes precedence over them. |
| 87 | func TestRequestHeaderOverridesTransportDefault(t *testing.T) { |
| 88 | reg := &httpmock.Registry{} |
| 89 | defer reg.Verify(t) |
| 90 | client := newTestClient(reg) |
| 91 | |
| 92 | reg.Register(httpmock.MatchAny, httpmock.StatusStringResponse(200, "{}")) |
| 93 | |
| 94 | resp, err := client.Request("github.com", http.MethodPost, "repos/OWNER/REPO/releases", nil, |
| 95 | WithHeader("Content-Type", "application/zip")) |
| 96 | require.NoError(t, err) |
| 97 | defer resp.Body.Close() |
| 98 | |
| 99 | assert.Equal(t, "application/zip", reg.Requests[0].Header.Get("Content-Type")) |
| 100 | } |
| 101 | |
| 102 | // Pre-auth call sites supply their own token because it is not yet in config, so an explicit |
| 103 | // Authorization header must survive rather than be replaced by the transport. |
nothing calls this directly
no test coverage detected