diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-12 18:17:54 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-12 18:17:54 -0600 |
| commit | a1fc674ab8ef8530f7fa217231a03da5166932da (patch) | |
| tree | f5f8e18097acaa15cb290a5f92c8b32bb10c7509 /test/integration/http.go | |
| parent | b8cb02c1fdb1513a17513b7950654983c8dc47dd (diff) | |
test: record http client requests
Diffstat (limited to 'test/integration/http.go')
| -rw-r--r-- | test/integration/http.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/integration/http.go b/test/integration/http.go index 8aeeb77..951d971 100644 --- a/test/integration/http.go +++ b/test/integration/http.go @@ -9,11 +9,22 @@ import ( "github.com/stretchr/testify/require" ) -var client *http.Client = &http.Client{ - Timeout: 5 * time.Second, +type testTransport struct { + t *testing.T +} + +func (r *testTransport) RoundTrip(request *http.Request) (*http.Response, error) { + response, err := http.DefaultTransport.RoundTrip(request) + r.t.Logf("%v %v %v %v\n", request.Method, request.URL, response.StatusCode, err) + return response, err } func HttpGet(t *testing.T, ctx context.Context, path string) *http.Response { + client := &http.Client{ + Timeout: 5 * time.Second, + Transport: &testTransport{t: t}, + } + request, err := http.NewRequestWithContext(ctx, http.MethodGet, path, nil) require.NoError(t, err) |
