Fixup URL assembly, add simple test
diff --git a/openstack/compute/v2/images/requests.go b/openstack/compute/v2/images/requests.go
index a755ea1..7ce5139 100644
--- a/openstack/compute/v2/images/requests.go
+++ b/openstack/compute/v2/images/requests.go
@@ -67,6 +67,6 @@
// Delete deletes the specified image ID.
func Delete(client *gophercloud.ServiceClient, id string) DeleteResult {
var result DeleteResult
- _, result.Err = client.Delete(getURL(client, id), nil)
+ _, result.Err = client.Delete(deleteURL(client, id), nil)
return result
}
diff --git a/openstack/compute/v2/images/requests_test.go b/openstack/compute/v2/images/requests_test.go
index 9a05f97..93a97bd 100644
--- a/openstack/compute/v2/images/requests_test.go
+++ b/openstack/compute/v2/images/requests_test.go
@@ -173,3 +173,19 @@
th.AssertNoErr(t, err)
th.CheckEquals(t, expected, actual)
}
+
+// Test Image delete
+func TestDeleteImage(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ th.Mux.HandleFunc("/images/12345678", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "DELETE")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+
+ w.WriteHeader(http.StatusNoContent)
+ })
+
+ res := Delete(fake.ServiceClient(), "12345678")
+ th.AssertNoErr(t, res.Err)
+}
diff --git a/openstack/compute/v2/images/urls.go b/openstack/compute/v2/images/urls.go
index 9b3c86d..b1bf103 100644
--- a/openstack/compute/v2/images/urls.go
+++ b/openstack/compute/v2/images/urls.go
@@ -9,3 +9,7 @@
func getURL(client *gophercloud.ServiceClient, id string) string {
return client.ServiceURL("images", id)
}
+
+func deleteURL(client *gophercloud.ServiceClient, id string) string {
+ return client.ServiceURL("images", id)
+}