1
0
mirror of https://github.com/golang/go synced 2024-11-27 01:11:20 -07:00

net/http: unset proxy environment after test

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>
This commit is contained in:
Chew Choon Keat 2017-03-13 03:21:21 +00:00 committed by Brad Fitzpatrick
parent dd0e1acfeb
commit eb715fbbbd
2 changed files with 2 additions and 1 deletions

View 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()
}

View 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)