(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func TestCustomHeaderTransportAddsCustomHeaders(t *testing.T) { |
| 148 | t.Parallel() |
| 149 | |
| 150 | customHeaders := http.Header{} |
| 151 | customHeaders.Set("Cookie", "CF_Authorization=token") |
| 152 | customHeaders.Set("X-Request-Id", "run-123") |
| 153 | |
| 154 | transport := newCustomHeaderTransport(roundTripFunc(func(req *http.Request) (*http.Response, error) { |
| 155 | require.Equal(t, "CF_Authorization=token", req.Header.Get("Cookie")) |
| 156 | require.Equal(t, "run-123", req.Header.Get("X-Request-Id")) |
| 157 | return &http.Response{ |
| 158 | StatusCode: http.StatusOK, |
| 159 | Header: make(http.Header), |
| 160 | Body: io.NopCloser(strings.NewReader("ok")), |
| 161 | Request: req, |
| 162 | }, nil |
| 163 | }), customHeaders) |
| 164 | |
| 165 | resp, err := transport.RoundTrip(httptest.NewRequest(http.MethodGet, "https://example.com", nil)) |
| 166 | require.NoError(t, err) |
| 167 | require.Equal(t, http.StatusOK, resp.StatusCode) |
| 168 | require.NoError(t, resp.Body.Close()) |
| 169 | } |
| 170 | |
| 171 | func TestCustomHeaderTransportClosesIdleConnections(t *testing.T) { |
| 172 | t.Parallel() |
nothing calls this directly
no test coverage detected