From ee7bf40967cd142ed1172596055dae2cc254df2c Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 16 Feb 2018 17:54:20 +0100 Subject: make govet happy --- shared_test.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'shared_test.go') diff --git a/shared_test.go b/shared_test.go index ba05453..91a9727 100644 --- a/shared_test.go +++ b/shared_test.go @@ -37,16 +37,19 @@ import ( //testcase like so: // // testWithAccount(t, func(a *Account) { -// useProxy(a, "http://localhost:8888") -// ... +// withProxy(a, "http://localhost:8888", func() { +// ... // // testWithContainer(t, func(c *Container) { -// useProxy(c.Account(), "http://localhost:8888") -// ... -func useProxy(a *Account, proxyURL string) { - t := *(http.DefaultTransport.(*http.Transport)) +// withProxy(c.Account(), "http://localhost:8888", func() { +// ... +func withProxy(a *Account, proxyURL string, action func()) { + t := http.DefaultTransport.(*http.Transport) + proxyOrig := t.Proxy t.Proxy = func(*http.Request) (*url.URL, error) { return url.Parse(proxyURL) } - a.client.ProviderClient.HTTPClient.Transport = &t + a.client.ProviderClient.HTTPClient.Transport = t + action() + t.Proxy = proxyOrig } func testWithAccount(t *testing.T, testCode func(a *Account)) { -- cgit v1.2.3