From 8f777460661bbbcbe42730979140f525b382110e Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Mon, 19 Feb 2018 20:51:16 +0100 Subject: introduce Client interface --- shared_test.go | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'shared_test.go') diff --git a/shared_test.go b/shared_test.go index 2c1d204..16113e2 100644 --- a/shared_test.go +++ b/shared_test.go @@ -23,8 +23,6 @@ import ( "crypto/rand" "encoding/hex" "math" - "net/http" - "net/url" "os" "testing" @@ -33,26 +31,6 @@ import ( "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth" ) -//This function can be used during debugging to redirect the HTTP requests for -//a specific unit test through a mitmproxy. Put this at the beginning of your -//testcase like so: -// -// testWithAccount(t, func(a *Account) { -// withProxy(a, "http://localhost:8888", func() { -// ... -// -// testWithContainer(t, func(c *Container) { -// 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 - action() - t.Proxy = proxyOrig -} - func testWithAccount(t *testing.T, testCode func(a *Account)) { stAuth := os.Getenv("ST_AUTH") stUser := os.Getenv("ST_USER") @@ -91,9 +69,9 @@ func testWithAccount(t *testing.T, testCode func(a *Account)) { } } - account, err := AccountFromClient(client) + account, err := AccountFromGophercloud(client) if err != nil { - t.Errorf("schwift.AccountFromClient returned: " + err.Error()) + t.Errorf("schwift.AccountFromGophercloud returned: " + err.Error()) return } testCode(account) -- cgit v1.2.3