aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/export_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2018-07-24 00:24:49 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-07-24 03:21:35 +0000
commit6df4c3a44b20b9738ae5699fbc156052522f9f54 (patch)
tree78b6f2a4493e1f82c1caaa487aeffe5adbb4e51d /src/net/http/export_test.go
parent416676f4d9bb2e14bce4e396c2ce67d091264751 (diff)
downloadgo-6df4c3a44b20b9738ae5699fbc156052522f9f54.tar.xz
net/http: document that Client methods always return *url.Error
Updates #9424 Change-Id: If117ba3e7d031f84b30d3a721ef99fe622734de2 Reviewed-on: https://go-review.googlesource.com/125575 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/net/http/export_test.go')
-rw-r--r--src/net/http/export_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go
index 5ff85bc7c8..bc0db53a2c 100644
--- a/src/net/http/export_test.go
+++ b/src/net/http/export_test.go
@@ -9,7 +9,9 @@ package http
import (
"context"
+ "fmt"
"net"
+ "net/url"
"sort"
"sync"
"testing"
@@ -40,6 +42,21 @@ func init() {
// When not under test, these values are always nil
// and never assigned to.
testHookMu = new(sync.Mutex)
+
+ testHookClientDoResult = func(res *Response, err error) {
+ if err != nil {
+ if _, ok := err.(*url.Error); !ok {
+ panic(fmt.Sprintf("unexpected Client.Do error of type %T; want *url.Error", err))
+ }
+ } else {
+ if res == nil {
+ panic("Client.Do returned nil, nil")
+ }
+ if res.Body == nil {
+ panic("Client.Do returned nil res.Body and no error")
+ }
+ }
+ }
}
var (