(t *testing.T)
| 332 | } |
| 333 | |
| 334 | func TestNewHTTPClientLogHeadlineOnly(t *testing.T) { |
| 335 | // Under GH_DEBUG=api the client normally logs a full verbose trace. LogHeadlineOnly must keep it non-verbose, so |
| 336 | // only httpretty's head lines are emitted and the request/response header and body lines are suppressed. |
| 337 | t.Setenv("GH_DEBUG", "api") |
| 338 | |
| 339 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 340 | w.WriteHeader(http.StatusNoContent) |
| 341 | })) |
| 342 | defer ts.Close() |
| 343 | |
| 344 | ios, _, _, stderr := iostreams.Test() |
| 345 | client, err := NewHTTPClient(HTTPClientOptions{ |
| 346 | AppVersion: "v1.2.3", |
| 347 | Log: ios.ErrOut, |
| 348 | LogHeadlineOnly: true, |
| 349 | SkipDefaultHeaders: true, |
| 350 | }) |
| 351 | require.NoError(t, err) |
| 352 | |
| 353 | req, err := http.NewRequest("GET", ts.URL, nil) |
| 354 | require.NoError(t, err) |
| 355 | req.Host = "github.com" |
| 356 | |
| 357 | res, err := client.Do(req) |
| 358 | require.NoError(t, err) |
| 359 | assert.Equal(t, 204, res.StatusCode) |
| 360 | |
| 361 | assert.Equal(t, heredoc.Doc(` |
| 362 | * Request at <time> |
| 363 | * Request to http://<host>:<port> |
| 364 | * Request took <duration> |
| 365 | `), normalizeVerboseLog(stderr.String())) |
| 366 | } |
| 367 | |
| 368 | func TestHTTPClientRedirectAuthenticationHeaderHandling(t *testing.T) { |
| 369 | // Two servers stand in for two different hosts. A dial map lets the test |
nothing calls this directly
no test coverage detected