sfs/share: Delete share (#120)
diff --git a/openstack/sharedfilesystems/v2/shares/testing/fixtures.go b/openstack/sharedfilesystems/v2/shares/testing/fixtures.go
index 3f90946..00bdfe0 100644
--- a/openstack/sharedfilesystems/v2/shares/testing/fixtures.go
+++ b/openstack/sharedfilesystems/v2/shares/testing/fixtures.go
@@ -10,6 +10,7 @@
const (
shareEndpoint = "/shares"
+ shareID = "011d21e2-fbc3-4e4a-9993-9ea223f73264"
)
var createRequest = `{
@@ -78,3 +79,12 @@
fmt.Fprintf(w, createResponse)
})
}
+
+// MockDeleteResponse creates a mock delete response
+func MockDeleteResponse(t *testing.T) {
+ th.Mux.HandleFunc(shareEndpoint+"/"+shareID, func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "DELETE")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ w.WriteHeader(http.StatusAccepted)
+ })
+}
diff --git a/openstack/sharedfilesystems/v2/shares/testing/request_test.go b/openstack/sharedfilesystems/v2/shares/testing/request_test.go
index 6d69201..c4e811c 100644
--- a/openstack/sharedfilesystems/v2/shares/testing/request_test.go
+++ b/openstack/sharedfilesystems/v2/shares/testing/request_test.go
@@ -21,3 +21,13 @@
th.AssertEquals(t, n.Size, 1)
th.AssertEquals(t, n.ShareProto, "NFS")
}
+
+func TestDelete(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ MockDeleteResponse(t)
+
+ result := shares.Delete(client.ServiceClient(), shareID)
+ th.AssertNoErr(t, result.Err)
+}