Feature/filestorage sharenetworks update (#126)
* sfs: Add update for share networks
* sfs: Add acceptance tests for share network Update
* sfs: Add possiblity to update the network for share network
* sfs: Improve share network Update unit tests
* sfs: Improve share network Update acceptance tests
diff --git a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go b/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
index b9876d5..1a4ae9b 100644
--- a/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
+++ b/acceptance/openstack/sharedfilesystems/v2/sharenetworks_test.go
@@ -6,6 +6,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/sharenetworks"
"github.com/gophercloud/gophercloud/pagination"
+ th "github.com/gophercloud/gophercloud/testhelper"
)
func TestShareNetworkCreateDestroy(t *testing.T) {
@@ -33,6 +34,54 @@
defer DeleteShareNetwork(t, client, shareNetwork)
}
+// Create a share network and update the name and description. Get the share
+// network and verify that the name and description have been updated
+func TestShareNetworkUpdate(t *testing.T) {
+ client, err := clients.NewSharedFileSystemV2Client()
+ if err != nil {
+ t.Fatalf("Unable to create shared file system client: %v", err)
+ }
+
+ shareNetwork, err := CreateShareNetwork(t, client)
+ if err != nil {
+ t.Fatalf("Unable to create share network: %v", err)
+ }
+
+ expectedShareNetwork, err := sharenetworks.Get(client, shareNetwork.ID).Extract()
+ if err != nil {
+ t.Errorf("Unable to retrieve shareNetwork: %v", err)
+ }
+
+ options := sharenetworks.UpdateOpts{
+ Name: "NewName",
+ Description: "New share network description",
+ NovaNetID: "New_nova_network_id",
+ }
+
+ expectedShareNetwork.Name = options.Name
+ expectedShareNetwork.Description = options.Description
+ expectedShareNetwork.NovaNetID = options.NovaNetID
+
+ _, err = sharenetworks.Update(client, shareNetwork.ID, options).Extract()
+ if err != nil {
+ t.Errorf("Unable to update shareNetwork: %v", err)
+ }
+
+ updatedShareNetwork, err := sharenetworks.Get(client, shareNetwork.ID).Extract()
+ if err != nil {
+ t.Errorf("Unable to retrieve shareNetwork: %v", err)
+ }
+
+ // Update time has to be set in order to get the assert equal to pass
+ expectedShareNetwork.UpdatedAt = updatedShareNetwork.UpdatedAt
+
+ th.CheckDeepEquals(t, expectedShareNetwork, updatedShareNetwork)
+
+ PrintShareNetwork(t, shareNetwork)
+
+ defer DeleteShareNetwork(t, client, shareNetwork)
+}
+
func TestShareNetworkListDetail(t *testing.T) {
client, err := clients.NewSharedFileSystemV2Client()
if err != nil {