diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go index fc28c8ab58c..7c71da139a1 100644 --- a/src/net/http/client_test.go +++ b/src/net/http/client_test.go @@ -2128,15 +2128,17 @@ func testProbeZeroLengthBody(t *testing.T, mode testMode) { } } -func TestClientTimeoutErrorWrapping(t *testing.T) { run(t, testClientTimeoutErrorWrapping) } -func testClientTimeoutErrorWrapping(t *testing.T, mode testMode) { +func TestClientTimeoutReturnsContextDeadlineExceeded(t *testing.T) { + run(t, testClientTimeoutReturnsContextDeadlineExceeded) +} +func testClientTimeoutReturnsContextDeadlineExceeded(t *testing.T, mode testMode) { doneCh := make(chan struct{}) defer close(doneCh) cst := newClientServerTest(t, mode, HandlerFunc(func(w ResponseWriter, r *Request) { <-doneCh w.WriteHeader(200) })) - // simulate a timeout and check that the error is wrapped by using errors.Is(err, context.DeadlineExceeded) + // check that, upon exceeding Client.Timeout, the returned error is context.DeadlineExceeded. cst.c.Timeout = 1 * time.Millisecond req, _ := NewRequest("GET", cst.ts.URL, nil) _, err := cst.c.Do(req)