Use Extract() methods in acceptance tests.
diff --git a/acceptance/openstack/compute/v2/compute_test.go b/acceptance/openstack/compute/v2/compute_test.go
index f5d0a65..15b5163 100644
--- a/acceptance/openstack/compute/v2/compute_test.go
+++ b/acceptance/openstack/compute/v2/compute_test.go
@@ -32,11 +32,7 @@
func waitForStatus(client *gophercloud.ServiceClient, server *servers.Server, status string) error {
return tools.WaitFor(func() (bool, error) {
- response, err := servers.Get(client, server.ID)
- if err != nil {
- return false, err
- }
- latest, err := servers.ExtractServer(response)
+ latest, err := servers.Get(client, server.ID).Extract()
if err != nil {
return false, err
}
diff --git a/acceptance/openstack/compute/v2/flavors_test.go b/acceptance/openstack/compute/v2/flavors_test.go
index f69be6b..ca810bc 100644
--- a/acceptance/openstack/compute/v2/flavors_test.go
+++ b/acceptance/openstack/compute/v2/flavors_test.go
@@ -48,14 +48,10 @@
t.Fatal(err)
}
- result, err := flavors.Get(client, choices.FlavorID)
+ flavor, err := flavors.Get(client, choices.FlavorID).Extract()
if err != nil {
t.Fatalf("Unable to get flavor information: %v", err)
}
- flavor, err := flavors.ExtractFlavor(result)
- if err != nil {
- t.Fatalf("Unable to extract flavor from GET result: %v", err)
- }
t.Logf("Flavor: %#v", flavor)
}
diff --git a/acceptance/openstack/compute/v2/servers_test.go b/acceptance/openstack/compute/v2/servers_test.go
index e1579ce..620ef1b 100644
--- a/acceptance/openstack/compute/v2/servers_test.go
+++ b/acceptance/openstack/compute/v2/servers_test.go
@@ -50,12 +50,12 @@
"flavorRef": choices.FlavorID,
"imageRef": choices.ImageID,
"name": name,
- })
+ }).Extract()
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
- return servers.ExtractServer(server)
+ return server, err
}
func TestCreateDestroyServer(t *testing.T) {
@@ -114,27 +114,19 @@
t.Logf("Attempting to rename the server to %s.", alternateName)
- result, err := servers.Update(client, server.ID, map[string]interface{}{
+ updated, err := servers.Update(client, server.ID, map[string]interface{}{
"name": alternateName,
- })
+ }).Extract()
if err != nil {
t.Fatalf("Unable to rename server: %v", err)
}
- updated, err := servers.ExtractServer(result)
- if err != nil {
- t.Fatalf("Unable to extract server: %v", err)
- }
if updated.ID != server.ID {
t.Errorf("Updated server ID [%s] didn't match original server ID [%s]!", updated.ID, server.ID)
}
err = tools.WaitFor(func() (bool, error) {
- result, err := servers.Get(client, updated.ID)
- if err != nil {
- return false, err
- }
- latest, err := servers.ExtractServer(result)
+ latest, err := servers.Get(client, updated.ID).Extract()
if err != nil {
return false, err
}
@@ -251,15 +243,11 @@
newPassword := tools.MakeNewPassword(server.AdminPass)
newName := tools.RandomString("ACPTTEST", 16)
- result, err := servers.Rebuild(client, server.ID, newName, newPassword, choices.ImageID, nil)
+ rebuilt, err := servers.Rebuild(client, server.ID, newName, newPassword, choices.ImageID, nil).Extract()
if err != nil {
t.Fatal(err)
}
- rebuilt, err := servers.ExtractServer(result)
- if err != nil {
- t.Fatal(err)
- }
if rebuilt.ID != server.ID {
t.Errorf("Expected rebuilt server ID of [%s]; got [%s]", server.ID, rebuilt.ID)
}
diff --git a/acceptance/openstack/networking/v2/network_test.go b/acceptance/openstack/networking/v2/network_test.go
index 9f18597..f00edba 100644
--- a/acceptance/openstack/networking/v2/network_test.go
+++ b/acceptance/openstack/networking/v2/network_test.go
@@ -18,6 +18,7 @@
// Create a network
n, err := networks.Create(Client, networks.CreateOpts{Name: "sample_network", AdminStateUp: true}).Extract()
th.AssertNoErr(t, err)
+ defer networks.Delete(Client, n.ID)
th.AssertEquals(t, n.Name, "sample_network")
th.AssertEquals(t, n.AdminStateUp, true)
networkID := n.ID