Compute v2: Extended Availability Zone Status (#282)
* Compute v2: Extended Availability Zone Status API
* Compute v2: Extended Availability Zone Status unit tests
* Compute v2: Extended Availability Zone Status acceptance tests
diff --git a/openstack/compute/v2/servers/testing/requests_test.go b/openstack/compute/v2/servers/testing/requests_test.go
index 15d6eb5..05712f7 100644
--- a/openstack/compute/v2/servers/testing/requests_test.go
+++ b/openstack/compute/v2/servers/testing/requests_test.go
@@ -6,6 +6,7 @@
"net/http"
"testing"
+ "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
@@ -56,6 +57,26 @@
th.CheckDeepEquals(t, ServerDerp, actual[1])
}
+func TestListAllServersWithExtensions(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleServerListSuccessfully(t)
+
+ type ServerWithExt struct {
+ servers.Server
+ availabilityzones.ServerExt
+ }
+
+ allPages, err := servers.List(client.ServiceClient(), servers.ListOpts{}).AllPages()
+ th.AssertNoErr(t, err)
+
+ var actual []ServerWithExt
+ err = servers.ExtractServersInto(allPages, &actual)
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, 3, len(actual))
+ th.AssertEquals(t, "nova", actual[0].AvailabilityZone)
+}
+
func TestCreateServer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
@@ -189,6 +210,26 @@
th.CheckDeepEquals(t, ServerDerp, *actual)
}
+func TestGetServerWithExtensions(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleServerGetSuccessfully(t)
+
+ var s struct {
+ servers.Server
+ availabilityzones.ServerExt
+ }
+
+ err := servers.Get(client.ServiceClient(), "1234asdf").ExtractInto(&s)
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, "nova", s.AvailabilityZone)
+
+ err = servers.Get(client.ServiceClient(), "1234asdf").ExtractInto(s)
+ if err == nil {
+ t.Errorf("Expected error when providing non-pointer struct")
+ }
+}
+
func TestUpdateServer(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()