]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: unset proxy environment after test
authorChew Choon Keat <choonkeat@gmail.com>
Mon, 13 Mar 2017 03:21:21 +0000 (03:21 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 13 Mar 2017 16:35:49 +0000 (16:35 +0000)
Fix last proxy in TestProxyFromEnvironment bleeds into other tests
Change ResetProxyEnv to use the newer os.Unsetenv, instead of hard
coding as ""

Change-Id: I67cf833dbcf4bec2e10ea73c354334160cf05f84
Reviewed-on: https://go-review.googlesource.com/38115
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/proxy_test.go
src/net/http/transport_test.go

index 823d1447ee91a9190a222c44a7420378dc6355cb..8d3a78b9621b53f1ce85498c15718027926263a7 100644 (file)
@@ -75,7 +75,7 @@ func TestCacheKeys(t *testing.T) {
 
 func ResetProxyEnv() {
        for _, v := range []string{"HTTP_PROXY", "http_proxy", "NO_PROXY", "no_proxy"} {
-               os.Setenv(v, "")
+               os.Unsetenv(v)
        }
        ResetCachedEnvironment()
 }
index 09bfef4b10df8d357b224f17ac3c7672b6c12a0a..8e211aad27d3c2599162ede5692d545a16620c49 100644 (file)
@@ -2243,6 +2243,7 @@ var proxyFromEnvTests = []proxyFromEnvTest{
 
 func TestProxyFromEnvironment(t *testing.T) {
        ResetProxyEnv()
+       defer ResetProxyEnv()
        for _, tt := range proxyFromEnvTests {
                os.Setenv("HTTP_PROXY", tt.env)
                os.Setenv("HTTPS_PROXY", tt.httpsenv)