Updating tests to use new import path
diff --git a/openstack/networking/v2/extensions/external/results_test.go b/openstack/networking/v2/extensions/external/results_test.go
index 397a78c..41bc0c8 100644
--- a/openstack/networking/v2/extensions/external/results_test.go
+++ b/openstack/networking/v2/extensions/external/results_test.go
@@ -8,6 +8,7 @@
"github.com/rackspace/gophercloud/openstack/networking/v2/networks"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestList(t *testing.T) {
@@ -16,7 +17,7 @@
th.Mux.HandleFunc("/v2.0/networks", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -55,7 +56,7 @@
count := 0
- networks.List(th.ServiceClient(), networks.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ networks.List(fake.ServiceClient(), networks.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractList(page)
if err != nil {
@@ -102,7 +103,7 @@
th.Mux.HandleFunc("/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -125,7 +126,7 @@
`)
})
- res := networks.Get(th.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
+ res := networks.Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
n, err := ExtractGet(res)
th.AssertNoErr(t, err)
@@ -138,7 +139,7 @@
th.Mux.HandleFunc("/v2.0/networks", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -173,7 +174,7 @@
})
options := CreateOpts{networks.CreateOpts{Name: "ext_net", AdminStateUp: Up}, true}
- res := networks.Create(th.ServiceClient(), options)
+ res := networks.Create(fake.ServiceClient(), options)
n, err := ExtractCreate(res)
@@ -187,7 +188,7 @@
th.Mux.HandleFunc("/v2.0/networks/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -221,7 +222,7 @@
})
options := UpdateOpts{networks.UpdateOpts{Name: "new_name"}, true}
- res := networks.Update(th.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options)
+ res := networks.Update(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options)
n, err := ExtractUpdate(res)
th.AssertNoErr(t, err)
diff --git a/openstack/networking/v2/extensions/layer3/floatingips/requests_test.go b/openstack/networking/v2/extensions/layer3/floatingips/requests_test.go
index 4940f50..b9153fc 100644
--- a/openstack/networking/v2/extensions/layer3/floatingips/requests_test.go
+++ b/openstack/networking/v2/extensions/layer3/floatingips/requests_test.go
@@ -7,6 +7,7 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestList(t *testing.T) {
@@ -15,7 +16,7 @@
th.Mux.HandleFunc("/v2.0/floatingips", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -50,7 +51,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractFloatingIPs(page)
if err != nil {
@@ -95,7 +96,7 @@
th.Mux.HandleFunc("/v2.0/floatingips", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -130,7 +131,7 @@
PortID: "ce705c24-c1ef-408a-bda3-7bbd946164ab",
}
- ip, err := Create(th.ServiceClient(), options).Extract()
+ ip, err := Create(fake.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "2f245a7b-796b-4f26-9cf9-9e82d248fda7", ip.ID)
@@ -147,7 +148,7 @@
th.Mux.HandleFunc("/v2.0/floatingips/2f245a7b-796b-4f26-9cf9-9e82d248fda7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -167,7 +168,7 @@
`)
})
- ip, err := Get(th.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7").Extract()
+ ip, err := Get(fake.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "90f742b1-6d17-487b-ba95-71881dbc0b64", ip.FloatingNetworkID)
@@ -185,7 +186,7 @@
th.Mux.HandleFunc("/v2.0/floatingips/2f245a7b-796b-4f26-9cf9-9e82d248fda7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -214,7 +215,7 @@
`)
})
- ip, err := Update(th.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7", UpdateOpts{PortID: "423abc8d-2991-4a55-ba98-2aaea84cc72e"}).Extract()
+ ip, err := Update(fake.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7", UpdateOpts{PortID: "423abc8d-2991-4a55-ba98-2aaea84cc72e"}).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, "423abc8d-2991-4a55-ba98-2aaea84cc72e", ip.PortID)
@@ -226,7 +227,7 @@
th.Mux.HandleFunc("/v2.0/floatingips/2f245a7b-796b-4f26-9cf9-9e82d248fda7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -255,7 +256,7 @@
`)
})
- ip, err := Update(th.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7", UpdateOpts{}).Extract()
+ ip, err := Update(fake.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7", UpdateOpts{}).Extract()
th.AssertNoErr(t, err)
th.AssertDeepEquals(t, "", ip.FixedIP)
@@ -268,10 +269,10 @@
th.Mux.HandleFunc("/v2.0/floatingips/2f245a7b-796b-4f26-9cf9-9e82d248fda7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7")
+ res := Delete(fake.ServiceClient(), "2f245a7b-796b-4f26-9cf9-9e82d248fda7")
th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/layer3/routers/requests_test.go b/openstack/networking/v2/extensions/layer3/routers/requests_test.go
index 4ce4d24..56a0d74 100755
--- a/openstack/networking/v2/extensions/layer3/routers/requests_test.go
+++ b/openstack/networking/v2/extensions/layer3/routers/requests_test.go
@@ -7,13 +7,14 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/routers", rootURL(th.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/routers", rootURL(fake.ServiceClient()))
}
func TestList(t *testing.T) {
@@ -22,7 +23,7 @@
th.Mux.HandleFunc("/v2.0/routers", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -55,7 +56,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractRouters(page)
if err != nil {
@@ -98,7 +99,7 @@
th.Mux.HandleFunc("/v2.0/routers", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -140,7 +141,7 @@
AdminStateUp: &asu,
GatewayInfo: &gwi,
}
- r, err := Create(th.ServiceClient(), options).Extract()
+ r, err := Create(fake.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "foo_router", r.Name)
@@ -154,7 +155,7 @@
th.Mux.HandleFunc("/v2.0/routers/a07eea83-7710-4860-931b-5fe220fae533", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -175,7 +176,7 @@
`)
})
- n, err := Get(th.ServiceClient(), "a07eea83-7710-4860-931b-5fe220fae533").Extract()
+ n, err := Get(fake.ServiceClient(), "a07eea83-7710-4860-931b-5fe220fae533").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, n.Status, "ACTIVE")
@@ -192,7 +193,7 @@
th.Mux.HandleFunc("/v2.0/routers/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -228,7 +229,7 @@
gwi := GatewayInfo{NetworkID: "8ca37218-28ff-41cb-9b10-039601ea7e6b"}
options := UpdateOpts{Name: "new_name", GatewayInfo: &gwi}
- n, err := Update(th.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options).Extract()
+ n, err := Update(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, n.Name, "new_name")
@@ -241,11 +242,11 @@
th.Mux.HandleFunc("/v2.0/routers/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
+ res := Delete(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c")
th.AssertNoErr(t, res.Err)
}
@@ -255,7 +256,7 @@
th.Mux.HandleFunc("/v2.0/routers/4e8e5957-649f-477b-9e5b-f1f75b21c03c/add_router_interface", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -278,7 +279,7 @@
})
opts := InterfaceOpts{SubnetID: "a2f1f29d-571b-4533-907f-5803ab96ead1"}
- res, err := AddInterface(th.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", opts).Extract()
+ res, err := AddInterface(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", opts).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "0d32a837-8069-4ec3-84c4-3eef3e10b188", res.SubnetID)
@@ -293,7 +294,7 @@
th.Mux.HandleFunc("/v2.0/routers/4e8e5957-649f-477b-9e5b-f1f75b21c03c/remove_router_interface", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -316,7 +317,7 @@
})
opts := InterfaceOpts{SubnetID: "a2f1f29d-571b-4533-907f-5803ab96ead1"}
- res, err := RemoveInterface(th.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", opts).Extract()
+ res, err := RemoveInterface(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", opts).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "0d32a837-8069-4ec3-84c4-3eef3e10b188", res.SubnetID)
diff --git a/openstack/networking/v2/extensions/lbaas/members/requests_test.go b/openstack/networking/v2/extensions/lbaas/members/requests_test.go
index 21746cb..cae3524 100644
--- a/openstack/networking/v2/extensions/lbaas/members/requests_test.go
+++ b/openstack/networking/v2/extensions/lbaas/members/requests_test.go
@@ -7,13 +7,14 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/lb/members", rootURL(th.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/lb/members", rootURL(fake.ServiceClient()))
}
func TestList(t *testing.T) {
@@ -22,7 +23,7 @@
th.Mux.HandleFunc("/v2.0/lb/members", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -57,7 +58,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractMembers(page)
if err != nil {
@@ -104,7 +105,7 @@
th.Mux.HandleFunc("/v2.0/lb/members", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -142,7 +143,7 @@
ProtocolPort: 8080,
PoolID: "foo",
}
- _, err := Create(th.ServiceClient(), options).Extract()
+ _, err := Create(fake.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
}
@@ -152,7 +153,7 @@
th.Mux.HandleFunc("/v2.0/lb/members/975592ca-e308-48ad-8298-731935ee9f45", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -172,7 +173,7 @@
`)
})
- m, err := Get(th.ServiceClient(), "975592ca-e308-48ad-8298-731935ee9f45").Extract()
+ m, err := Get(fake.ServiceClient(), "975592ca-e308-48ad-8298-731935ee9f45").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "975592ca-e308-48ad-8298-731935ee9f45", m.ID)
@@ -190,7 +191,7 @@
th.Mux.HandleFunc("/v2.0/lb/members/332abe93-f488-41ba-870b-2ac66be7f853", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -223,7 +224,7 @@
options := UpdateOpts{AdminStateUp: false}
- _, err := Update(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", options).Extract()
+ _, err := Update(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", options).Extract()
th.AssertNoErr(t, err)
}
@@ -233,10 +234,10 @@
th.Mux.HandleFunc("/v2.0/lb/members/332abe93-f488-41ba-870b-2ac66be7f853", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853")
+ res := Delete(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853")
th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go b/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go
index 14c80bf..68a3288 100644
--- a/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go
+++ b/openstack/networking/v2/extensions/lbaas/monitors/requests_test.go
@@ -7,12 +7,13 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/lb/health_monitors", rootURL(th.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/lb/health_monitors", rootURL(fake.ServiceClient()))
}
func TestList(t *testing.T) {
@@ -21,7 +22,7 @@
th.Mux.HandleFunc("/v2.0/lb/health_monitors", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -57,7 +58,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractMonitors(page)
if err != nil {
@@ -105,7 +106,7 @@
th.Mux.HandleFunc("/v2.0/lb/health_monitors", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -144,7 +145,7 @@
`)
})
- _, err := Create(th.ServiceClient(), CreateOpts{
+ _, err := Create(fake.ServiceClient(), CreateOpts{
Type: "HTTP",
TenantID: "453105b9-1754-413f-aab1-55f1af620750",
Delay: 20,
@@ -163,7 +164,7 @@
th.Mux.HandleFunc("/v2.0/lb/health_monitors/f3eeab00-8367-4524-b662-55e64d4cacb5", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -187,7 +188,7 @@
`)
})
- hm, err := Get(th.ServiceClient(), "f3eeab00-8367-4524-b662-55e64d4cacb5").Extract()
+ hm, err := Get(fake.ServiceClient(), "f3eeab00-8367-4524-b662-55e64d4cacb5").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "f3eeab00-8367-4524-b662-55e64d4cacb5", hm.ID)
@@ -209,7 +210,7 @@
th.Mux.HandleFunc("/v2.0/lb/health_monitors/b05e44b5-81f9-4551-b474-711a722698f7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -250,7 +251,7 @@
`)
})
- _, err := Update(th.ServiceClient(), "b05e44b5-81f9-4551-b474-711a722698f7", UpdateOpts{
+ _, err := Update(fake.ServiceClient(), "b05e44b5-81f9-4551-b474-711a722698f7", UpdateOpts{
Delay: 3,
Timeout: 20,
MaxRetries: 10,
@@ -267,10 +268,10 @@
th.Mux.HandleFunc("/v2.0/lb/health_monitors/b05e44b5-81f9-4551-b474-711a722698f7", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "b05e44b5-81f9-4551-b474-711a722698f7")
+ res := Delete(fake.ServiceClient(), "b05e44b5-81f9-4551-b474-711a722698f7")
th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/lbaas/pools/requests_test.go b/openstack/networking/v2/extensions/lbaas/pools/requests_test.go
index a8d447b..6af47a1 100644
--- a/openstack/networking/v2/extensions/lbaas/pools/requests_test.go
+++ b/openstack/networking/v2/extensions/lbaas/pools/requests_test.go
@@ -7,13 +7,14 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/lb/pools", rootURL(th.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/lb/pools", rootURL(fake.ServiceClient()))
}
func TestList(t *testing.T) {
@@ -22,7 +23,7 @@
th.Mux.HandleFunc("/v2.0/lb/pools", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -60,7 +61,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractPools(page)
if err != nil {
@@ -108,7 +109,7 @@
th.Mux.HandleFunc("/v2.0/lb/pools", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -155,7 +156,7 @@
SubnetID: "1981f108-3c48-48d2-b908-30f7d28532c9",
TenantID: "2ffc6e22aae24e4795f87155d24c896f",
}
- p, err := Create(th.ServiceClient(), options).Extract()
+ p, err := Create(fake.ServiceClient(), options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "PENDING_CREATE", p.Status)
@@ -176,7 +177,7 @@
th.Mux.HandleFunc("/v2.0/lb/pools/332abe93-f488-41ba-870b-2ac66be7f853", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -202,7 +203,7 @@
`)
})
- n, err := Get(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853").Extract()
+ n, err := Get(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, n.ID, "332abe93-f488-41ba-870b-2ac66be7f853")
@@ -214,7 +215,7 @@
th.Mux.HandleFunc("/v2.0/lb/pools/332abe93-f488-41ba-870b-2ac66be7f853", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -255,7 +256,7 @@
options := UpdateOpts{Name: "SuperPool", LBMethod: LBMethodLeastConnections}
- n, err := Update(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", options).Extract()
+ n, err := Update(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "SuperPool", n.Name)
@@ -268,11 +269,11 @@
th.Mux.HandleFunc("/v2.0/lb/pools/332abe93-f488-41ba-870b-2ac66be7f853", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853")
+ res := Delete(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853")
th.AssertNoErr(t, res.Err)
}
@@ -282,7 +283,7 @@
th.Mux.HandleFunc("/v2.0/lb/pools/332abe93-f488-41ba-870b-2ac66be7f853/health_monitors", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -297,7 +298,7 @@
w.WriteHeader(http.StatusCreated)
})
- _, err := AssociateMonitor(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", "b624decf-d5d3-4c66-9a3d-f047e7786181").Extract()
+ _, err := AssociateMonitor(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", "b624decf-d5d3-4c66-9a3d-f047e7786181").Extract()
th.AssertNoErr(t, err)
}
@@ -307,10 +308,10 @@
th.Mux.HandleFunc("/v2.0/lb/pools/332abe93-f488-41ba-870b-2ac66be7f853/health_monitors/b624decf-d5d3-4c66-9a3d-f047e7786181", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := DisassociateMonitor(th.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", "b624decf-d5d3-4c66-9a3d-f047e7786181")
+ res := DisassociateMonitor(fake.ServiceClient(), "332abe93-f488-41ba-870b-2ac66be7f853", "b624decf-d5d3-4c66-9a3d-f047e7786181")
th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/lbaas/vips/requests_test.go b/openstack/networking/v2/extensions/lbaas/vips/requests_test.go
index 2fea421..f4e90c7 100644
--- a/openstack/networking/v2/extensions/lbaas/vips/requests_test.go
+++ b/openstack/networking/v2/extensions/lbaas/vips/requests_test.go
@@ -7,14 +7,15 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/lb/vips", rootURL(th.ServiceClient()))
- th.AssertEquals(t, th.Endpoint()+"v2.0/lb/vips/foo", resourceURL(th.ServiceClient(), "foo"))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/lb/vips", rootURL(fake.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/lb/vips/foo", resourceURL(fake.ServiceClient(), "foo"))
}
func TestList(t *testing.T) {
@@ -23,7 +24,7 @@
th.Mux.HandleFunc("/v2.0/lb/vips", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -68,7 +69,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractVIPs(page)
if err != nil {
@@ -127,7 +128,7 @@
th.Mux.HandleFunc("/v2.0/lb/vips", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -176,7 +177,7 @@
ProtocolPort: 80,
}
- r, err := Create(th.ServiceClient(), opts).Extract()
+ r, err := Create(fake.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "PENDING_CREATE", r.Status)
@@ -200,7 +201,7 @@
th.Mux.HandleFunc("/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -230,7 +231,7 @@
`)
})
- vip, err := Get(th.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304").Extract()
+ vip, err := Get(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "ACTIVE", vip.Status)
@@ -247,7 +248,7 @@
th.Mux.HandleFunc("/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -284,7 +285,7 @@
i1000 := 1000
options := UpdateOpts{ConnLimit: &i1000}
- vip, err := Update(th.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304", options).Extract()
+ vip, err := Update(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304", options).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "PENDING_UPDATE", vip.Status)
@@ -297,10 +298,10 @@
th.Mux.HandleFunc("/v2.0/lb/vips/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
+ res := Delete(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/provider/results_test.go b/openstack/networking/v2/extensions/provider/results_test.go
index 1bac060..ec0b528 100644
--- a/openstack/networking/v2/extensions/provider/results_test.go
+++ b/openstack/networking/v2/extensions/provider/results_test.go
@@ -8,6 +8,7 @@
"github.com/rackspace/gophercloud/openstack/networking/v2/networks"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestList(t *testing.T) {
@@ -16,7 +17,7 @@
th.Mux.HandleFunc("/v2.0/networks", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -59,7 +60,7 @@
count := 0
- networks.List(th.ServiceClient(), networks.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ networks.List(fake.ServiceClient(), networks.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractList(page)
if err != nil {
@@ -110,7 +111,7 @@
th.Mux.HandleFunc("/v2.0/networks/d32019d3-bc6e-4319-9c1d-6722fc136a22", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -135,7 +136,7 @@
`)
})
- res := networks.Get(th.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
+ res := networks.Get(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22")
n, err := ExtractGet(res)
th.AssertNoErr(t, err)
@@ -151,7 +152,7 @@
th.Mux.HandleFunc("/v2.0/networks", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -187,7 +188,7 @@
})
options := networks.CreateOpts{Name: "sample_network", AdminStateUp: Up}
- res := networks.Create(th.ServiceClient(), options)
+ res := networks.Create(fake.ServiceClient(), options)
n, err := ExtractCreate(res)
th.AssertNoErr(t, err)
@@ -203,7 +204,7 @@
th.Mux.HandleFunc("/v2.0/networks/4e8e5957-649f-477b-9e5b-f1f75b21c03c", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PUT")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -241,7 +242,7 @@
iTrue := true
options := networks.UpdateOpts{Name: "new_network_name", AdminStateUp: Down, Shared: &iTrue}
- res := networks.Update(th.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options)
+ res := networks.Update(fake.ServiceClient(), "4e8e5957-649f-477b-9e5b-f1f75b21c03c", options)
n, err := ExtractUpdate(res)
th.AssertNoErr(t, err)
diff --git a/openstack/networking/v2/extensions/requests_test.go b/openstack/networking/v2/extensions/requests_test.go
index ac78747..db21772 100755
--- a/openstack/networking/v2/extensions/requests_test.go
+++ b/openstack/networking/v2/extensions/requests_test.go
@@ -7,6 +7,7 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestList(t *testing.T) {
@@ -15,7 +16,7 @@
th.Mux.HandleFunc("/v2.0/extensions", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
@@ -37,7 +38,7 @@
count := 0
- List(th.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractExtensions(page)
if err != nil {
@@ -71,7 +72,7 @@
th.Mux.HandleFunc("/v2.0/extensions/agent", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -89,7 +90,7 @@
}
`)
- ext, err := Get(th.ServiceClient(), "agent").Extract()
+ ext, err := Get(fake.ServiceClient(), "agent").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, ext.Updated, "2013-02-03T10:00:00-00:00")
diff --git a/openstack/networking/v2/extensions/security/groups/requests_test.go b/openstack/networking/v2/extensions/security/groups/requests_test.go
index e6640d2..857bdc6 100644
--- a/openstack/networking/v2/extensions/security/groups/requests_test.go
+++ b/openstack/networking/v2/extensions/security/groups/requests_test.go
@@ -8,14 +8,15 @@
"github.com/rackspace/gophercloud/openstack/networking/v2/extensions/security/rules"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/security-groups", rootURL(th.ServiceClient()))
- th.AssertEquals(t, th.Endpoint()+"v2.0/security-groups/foo", resourceURL(th.ServiceClient(), "foo"))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/security-groups", rootURL(fake.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/security-groups/foo", resourceURL(fake.ServiceClient(), "foo"))
}
func TestList(t *testing.T) {
@@ -24,7 +25,7 @@
th.Mux.HandleFunc("/v2.0/security-groups", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -46,7 +47,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractGroups(page)
if err != nil {
@@ -80,7 +81,7 @@
th.Mux.HandleFunc("/v2.0/security-groups", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -134,7 +135,7 @@
})
opts := CreateOpts{Name: "new-webservers", Description: "security group for webservers"}
- _, err := Create(th.ServiceClient(), opts).Extract()
+ _, err := Create(fake.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
}
@@ -144,7 +145,7 @@
th.Mux.HandleFunc("/v2.0/security-groups/85cc3048-abc3-43cc-89b3-377341426ac5", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -187,7 +188,7 @@
`)
})
- sg, err := Get(th.ServiceClient(), "85cc3048-abc3-43cc-89b3-377341426ac5").Extract()
+ sg, err := Get(fake.ServiceClient(), "85cc3048-abc3-43cc-89b3-377341426ac5").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "default", sg.Description)
@@ -203,10 +204,10 @@
th.Mux.HandleFunc("/v2.0/security-groups/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
+ res := Delete(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
th.AssertNoErr(t, res.Err)
}
diff --git a/openstack/networking/v2/extensions/security/rules/requests_test.go b/openstack/networking/v2/extensions/security/rules/requests_test.go
index c968cd9..a2c7fbb 100644
--- a/openstack/networking/v2/extensions/security/rules/requests_test.go
+++ b/openstack/networking/v2/extensions/security/rules/requests_test.go
@@ -7,14 +7,15 @@
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
)
func TestURLs(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- th.AssertEquals(t, th.Endpoint()+"v2.0/security-group-rules", rootURL(th.ServiceClient()))
- th.AssertEquals(t, th.Endpoint()+"v2.0/security-group-rules/foo", resourceURL(th.ServiceClient(), "foo"))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/security-group-rules", rootURL(fake.ServiceClient()))
+ th.AssertEquals(t, th.Endpoint()+"v2.0/security-group-rules/foo", resourceURL(fake.ServiceClient(), "foo"))
}
func TestList(t *testing.T) {
@@ -23,7 +24,7 @@
th.Mux.HandleFunc("/v2.0/security-group-rules", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -62,7 +63,7 @@
count := 0
- List(th.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
+ List(fake.ServiceClient(), ListOpts{}).EachPage(func(page pagination.Page) (bool, error) {
count++
actual, err := ExtractRules(page)
if err != nil {
@@ -113,7 +114,7 @@
th.Mux.HandleFunc("/v2.0/security-group-rules", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "POST")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestHeader(t, r, "Content-Type", "application/json")
th.TestHeader(t, r, "Accept", "application/json")
th.TestJSONRequest(t, r, `
@@ -160,7 +161,7 @@
RemoteGroupID: "85cc3048-abc3-43cc-89b3-377341426ac5",
SecGroupID: "a7734e61-b545-452d-a3cd-0189cbd9747a",
}
- _, err := Create(th.ServiceClient(), opts).Extract()
+ _, err := Create(fake.ServiceClient(), opts).Extract()
th.AssertNoErr(t, err)
}
@@ -170,7 +171,7 @@
th.Mux.HandleFunc("/v2.0/security-group-rules/3c0e45ff-adaf-4124-b083-bf390e5482ff", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
@@ -193,7 +194,7 @@
`)
})
- sr, err := Get(th.ServiceClient(), "3c0e45ff-adaf-4124-b083-bf390e5482ff").Extract()
+ sr, err := Get(fake.ServiceClient(), "3c0e45ff-adaf-4124-b083-bf390e5482ff").Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, "egress", sr.Direction)
@@ -214,10 +215,10 @@
th.Mux.HandleFunc("/v2.0/security-group-rules/4ec89087-d057-4e2c-911f-60a3b47ee304", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "DELETE")
- th.TestHeader(t, r, "X-Auth-Token", th.TokenID)
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusNoContent)
})
- res := Delete(th.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
+ res := Delete(fake.ServiceClient(), "4ec89087-d057-4e2c-911f-60a3b47ee304")
th.AssertNoErr(t, res.Err)
}