diff options
| -rw-r--r-- | shared_test.go | 17 |
1 files changed, 10 insertions, 7 deletions
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)) { |
