Feature/filestorage sharenetworks delete (#122)
* sfs: Add delete for share networks
* sfs: Make name and descr required for creating share network
* sfs: Add acceptance test for share network Delete
* sfs: Remove required parameters
After taking a close look at the code it appeared that 'name'
and 'description' are not required parameters
diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go b/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go
index a964515..1f75e90 100644
--- a/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go
+++ b/acceptance/openstack/sharedfilesystems/v2/sharenetworks.go
@@ -31,6 +31,17 @@
return shareNetwork, nil
}
+// DeleteShareNetwork will delete a share network. An error will occur if
+// the share network was unable to be deleted.
+func DeleteShareNetwork(t *testing.T, client *gophercloud.ServiceClient, shareNetwork *sharenetworks.ShareNetwork) {
+ err := sharenetworks.Delete(client, shareNetwork.ID).ExtractErr()
+ if err != nil {
+ t.Fatalf("Failed to delete share network %s: %v", shareNetwork.ID, err)
+ }
+
+ t.Logf("Deleted share network: %s", shareNetwork.ID)
+}
+
// PrintShareNetwork will print a share network and all of its attributes.
func PrintShareNetwork(t *testing.T, sharenetwork *sharenetworks.ShareNetwork) {
t.Logf("ID: %s", sharenetwork.ID)
diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go b/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
index 6b74007..e654251 100644
--- a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
+++ b/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
@@ -6,7 +6,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
)
-func TestShareNetworkCreate(t *testing.T) {
+func TestShareNetworkCreateDestroy(t *testing.T) {
client, err := clients.NewSharedFileSystemV2Client()
if err != nil {
t.Fatalf("Unable to create shared file system client: %v", err)
@@ -17,7 +17,7 @@
t.Fatalf("Unable to create share network: %v", err)
}
- // TODO: delete the share network when the delete is implemented
-
PrintShareNetwork(t, shareNetwork)
+
+ defer DeleteShareNetwork(t, client, shareNetwork)
}