]> Cypherpunks repositories - gostls13.git/commit
net/http: use httptest.Server Client in tests
authorJohan Brandhorst <johan.brandhorst@gmail.com>
Sat, 4 Mar 2017 18:24:44 +0000 (18:24 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 8 Mar 2017 15:51:48 +0000 (15:51 +0000)
commit3b988eb643e6f2a1cae8981590891fd95e8112e5
treed4f4b2343d0ecfe685555b2b2cd7b75dd9811e13
parent2bd6360e3b0bda74b637ad37536b2f95f5b8574f
net/http: use httptest.Server Client in tests

After merging https://go-review.googlesource.com/c/34639/,
it was pointed out to me that a lot of tests under net/http
could use the new functionality to simplify and unify testing.

Using the httptest.Server provided Client removes the need to
call CloseIdleConnections() on all Transports created, as it
is automatically called on the Transport associated with the
client when Server.Close() is called.

Change the transport used by the non-TLS
httptest.Server to a new *http.Transport rather than using
http.DefaultTransport implicitly. The TLS version already
used its own *http.Transport. This change is to prevent
concurrency problems with using DefaultTransport implicitly
across several httptest.Server's.

Add tests to ensure the httptest.Server.Client().Transport
RoundTripper interface is implemented by a *http.Transport,
as is now assumed across large parts of net/http tests.

Change-Id: I9f9d15f59d72893deead5678d314388718c91821
Reviewed-on: https://go-review.googlesource.com/37771
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/client_test.go
src/net/http/fs_test.go
src/net/http/httptest/server.go
src/net/http/httptest/server_test.go
src/net/http/httputil/reverseproxy_test.go
src/net/http/main_test.go
src/net/http/npn_test.go
src/net/http/serve_test.go
src/net/http/transport_test.go