author | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-07-17 00:14:37 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2018-07-17 00:14:37 UTC |
parent | 9ef528c72690862297851edeb6c84cfac2e8979d |
dnss_test.go | +6 | -1 |
diff --git a/dnss_test.go b/dnss_test.go index 5150ed0..f6ad15f 100644 --- a/dnss_test.go +++ b/dnss_test.go @@ -25,6 +25,9 @@ func TestMain(m *testing.M) { flag.Parse() log.Init() log.Default.Level = log.Error + + // We need to do this early, see TestProxyServerDomain. + os.Setenv("HTTPS_PROXY", "http://proxy:1234/p") os.Exit(m.Run()) } @@ -202,7 +205,9 @@ func BenchmarkSimple(b *testing.B) { // for a single case. func TestProxyServerDomain(t *testing.T) { *httpsUpstream = "https://montoto/xyz" - os.Setenv("HTTPS_PROXY", "http://proxy:1234/p") + // In TestMain we set: HTTPS_PROXY=http://proxy:1234/p + // We have to do that earlier to prevent other tests from (indirectly) + // calling http.ProxyFromEnvironment and have it cache a nil result. if got := proxyServerDomain(); got != "proxy" { t.Errorf("got %q, expected 'proxy'", got) }