]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: remove use of DeepEqual for testing errors
authorMarcel van Lohuizen <mpvl@golang.org>
Fri, 8 Feb 2019 16:50:36 +0000 (17:50 +0100)
committerMarcel van Lohuizen <mpvl@golang.org>
Wed, 27 Feb 2019 18:24:06 +0000 (18:24 +0000)
Comparing errors using DeepEqual breaks if frame information
is added as proposed in Issue #29934.

Updates #29934.

Change-Id: I4ef076e262109a9d6f5b18846129df2535611d71
Reviewed-on: https://go-review.googlesource.com/c/162178
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/net/http/clientserver_test.go
src/net/http/transport.go

index 465bae147850b03c679001fd7ff638d5e1d72c4c..d61d77839d31d4068e32229224affaae8ae0dd91 100644 (file)
@@ -560,7 +560,7 @@ func testCancelRequestMidBody(t *testing.T, h2 bool) {
        if all != "Hello" {
                t.Errorf("Read %q (%q + %q); want Hello", all, firstRead, rest)
        }
-       if !reflect.DeepEqual(err, ExportErrRequestCanceled) {
+       if err != ExportErrRequestCanceled {
                t.Errorf("ReadAll error = %v; want %v", err, ExportErrRequestCanceled)
        }
 }
index a8c5efe6aaff2918498b0aa2f43d9c5adb91bd64..bb9657f4eeff72dc14bffac59323b63a7628a6d0 100644 (file)
@@ -2073,7 +2073,10 @@ func (e *httpError) Timeout() bool   { return e.timeout }
 func (e *httpError) Temporary() bool { return true }
 
 var errTimeout error = &httpError{err: "net/http: timeout awaiting response headers", timeout: true}
-var errRequestCanceled = errors.New("net/http: request canceled")
+
+// errRequestCanceled is set to be identical to the one from h2 to facilitate
+// testing.
+var errRequestCanceled = http2errRequestCanceled
 var errRequestCanceledConn = errors.New("net/http: request canceled while waiting for connection") // TODO: unify?
 
 func nop() {}