Commit 27a3d30d authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http: deflake TestClientRedirects

Fix another case of a parallel test relying on a global variable
(DefaultTransport) implicitly.

Use the private Transport already in scope instead. It's closed at the
end, instead of randomly via another test.

Change-Id: I95e51926177ad19a766cabbb306782ded1bbb59b
Reviewed-on: https://go-review.googlesource.com/32913
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 41eb9bb9
...@@ -251,11 +251,14 @@ func TestClientRedirects(t *testing.T) { ...@@ -251,11 +251,14 @@ func TestClientRedirects(t *testing.T) {
var checkErr error var checkErr error
var lastVia []*Request var lastVia []*Request
var lastReq *Request var lastReq *Request
c = &Client{CheckRedirect: func(req *Request, via []*Request) error { c = &Client{
Transport: tr,
CheckRedirect: func(req *Request, via []*Request) error {
lastReq = req lastReq = req
lastVia = via lastVia = via
return checkErr return checkErr
}} },
}
res, err := c.Get(ts.URL) res, err := c.Get(ts.URL)
if err != nil { if err != nil {
t.Fatalf("Get error: %v", err) t.Fatalf("Get error: %v", err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment