]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: simplify ctx.Err() call in test
authorSina Siadat <siadat@gmail.com>
Tue, 17 Oct 2017 10:20:26 +0000 (13:50 +0330)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 10 Nov 2017 06:04:37 +0000 (06:04 +0000)
See CL 40291. ctx.Err() is defined to only return non-nil exactly
when ctx.Done() returns a closed channel.

Change-Id: I12f51d8c42228f759273319b3ccc28012cb9fc73
Reviewed-on: https://go-review.googlesource.com/71310
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/serve_test.go

index 508d8b53f1c14ebc39fed39ae1ea5cdcdafcfd13..b000bf0e616ada25c7f11159524d1133158f8e6f 100644 (file)
@@ -686,12 +686,8 @@ func TestHTTP2WriteDeadlineExtendedOnNewRequest(t *testing.T) {
                req = req.WithContext(ctx)
 
                r, err := c.Do(req)
-               select {
-               case <-ctx.Done():
-                       if ctx.Err() == context.DeadlineExceeded {
-                               t.Fatalf("http2 Get #%d response timed out", i)
-                       }
-               default:
+               if ctx.Err() == context.DeadlineExceeded {
+                       t.Fatalf("http2 Get #%d response timed out", i)
                }
                if err != nil {
                        t.Fatalf("http2 Get #%d: %v", i, err)