Shuffled resources into sub-packages and upgraded to new pagination idiom
diff --git a/acceptance/openstack/networking/v2/apiversion_test.go b/acceptance/openstack/networking/v2/apiversion_test.go
new file mode 100644
index 0000000..79198c5
--- /dev/null
+++ b/acceptance/openstack/networking/v2/apiversion_test.go
@@ -0,0 +1,51 @@
+// +build acceptance networking
+
+package v2
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/networking/v2/apiversions"
+ th "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestListAPIVersions(t *testing.T) {
+ Setup(t)
+ defer Teardown()
+
+ pager := apiversions.ListVersions(Client)
+ err := pager.EachPage(func(page gophercloud.Page) (bool, error) {
+ t.Logf("--- Page ---")
+
+ versions, err := apiversions.ExtractAPIVersions(page)
+ th.AssertNoErr(t, err)
+
+ for _, v := range versions {
+ t.Logf("API Version: ID [%s] Status [%s]", v.ID, v.Status)
+ }
+
+ return true, nil
+ })
+ th.CheckNoErr(t, err)
+}
+
+func TestListAPIResources(t *testing.T) {
+ Setup(t)
+ defer Teardown()
+
+ pager := apiversions.ListVersionResources(Client, "v2.0")
+ err := pager.EachPage(func(page gophercloud.Page) (bool, error) {
+ t.Logf("--- Page ---")
+
+ vrs, err := apiversions.ExtractVersionResources(page)
+ th.AssertNoErr(t, err)
+
+ for _, vr := range vrs {
+ t.Logf("Network: Name [%s] Collection [%s]", vr.Name, vr.Collection)
+ }
+
+ return true, nil
+ })
+ th.CheckNoErr(t, err)
+}
diff --git a/acceptance/openstack/networking/v2/extension_test.go b/acceptance/openstack/networking/v2/extension_test.go
new file mode 100644
index 0000000..2cbe3a7
--- /dev/null
+++ b/acceptance/openstack/networking/v2/extension_test.go
@@ -0,0 +1,45 @@
+// +build acceptance networking
+
+package v2
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/networking/v2/extensions"
+ th "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestListExts(t *testing.T) {
+ Setup(t)
+ defer Teardown()
+
+ pager := extensions.List(Client)
+ err := pager.EachPage(func(page gophercloud.Page) (bool, error) {
+ t.Logf("--- Page ---")
+
+ exts, err := extensions.ExtractExtensions(page)
+ th.AssertNoErr(t, err)
+
+ for _, ext := range exts {
+ t.Logf("Extension: Name [%s] Description [%s]", ext.Name, ext.Description)
+ }
+
+ return true, nil
+ })
+ th.CheckNoErr(t, err)
+}
+
+func TestGetExt(t *testing.T) {
+ Setup(t)
+ defer Teardown()
+
+ ext, err := extensions.Get(Client, "service-type")
+ th.AssertNoErr(t, err)
+
+ th.AssertEquals(t, ext.Updated, "2013-01-20T00:00:00-00:00")
+ th.AssertEquals(t, ext.Name, "Neutron Service Type Management")
+ th.AssertEquals(t, ext.Namespace, "http://docs.openstack.org/ext/neutron/service-type/api/v1.0")
+ th.AssertEquals(t, ext.Alias, "service-type")
+ th.AssertEquals(t, ext.Description, "API for retrieving service providers for Neutron advanced services")
+}
diff --git a/acceptance/openstack/networking/v2/network_test.go b/acceptance/openstack/networking/v2/network_test.go
index 53b9f59..6eb7182 100644
--- a/acceptance/openstack/networking/v2/network_test.go
+++ b/acceptance/openstack/networking/v2/network_test.go
@@ -4,6 +4,7 @@
import (
"os"
+ "strconv"
"testing"
"github.com/rackspace/gophercloud"
@@ -13,9 +14,7 @@
th "github.com/rackspace/gophercloud/testhelper"
)
-var (
- Client *gophercloud.ServiceClient
-)
+var Client *gophercloud.ServiceClient
func NewClient() (*gophercloud.ServiceClient, error) {
opts, err := utils.AuthOptions()
@@ -44,60 +43,25 @@
Client = nil
}
-func TestListAPIVersions(t *testing.T) {
- Setup(t)
- defer Teardown()
-
- res, err := networks.APIVersions(Client)
- th.AssertNoErr(t, err)
-
- err = gophercloud.EachPage(res, func(page gophercloud.Collection) bool {
- t.Logf("--- Page ---")
- for _, v := range networks.ToAPIVersions(page) {
- t.Logf("API version: ID [%s] Status [%s]", v.ID, v.Status)
- }
- return true
- })
- th.AssertNoErr(t, err)
-}
-
-func TestGetApiInfo(t *testing.T) {
- Setup(t)
- defer Teardown()
-
- res, err := networks.APIInfo(Client, "v2.0")
- th.AssertNoErr(t, err)
-
- err = gophercloud.EachPage(res, func(page gophercloud.Collection) bool {
- t.Logf("--- Page ---")
- for _, r := range networks.ToAPIResource(page) {
- t.Logf("API resource: Name [%s] Collection [%s]", r.Name, r.Collection)
- }
- return true
- })
- th.AssertNoErr(t, err)
-}
-
-func TestListExts(t *testing.T) {
- //networks.Extensions()
-}
-
-func TestGetExt(t *testing.T) {
- Setup(t)
- defer Teardown()
-
- ext, err := networks.GetExtension(Client, "service-type")
- th.AssertNoErr(t, err)
-
- th.AssertEquals(t, ext.Updated, "2013-01-20T00:00:00-00:00")
- th.AssertEquals(t, ext.Name, "Neutron Service Type Management")
- th.AssertEquals(t, ext.Namespace, "http://docs.openstack.org/ext/neutron/service-type/api/v1.0")
- th.AssertEquals(t, ext.Alias, "service-type")
- th.AssertEquals(t, ext.Description, "API for retrieving service providers for Neutron advanced services")
-}
-
func TestListNetworks(t *testing.T) {
- //networks.List()
+ Setup(t)
+ defer Teardown()
+
+ pager := networks.List(Client, networks.ListOpts{})
+ err := pager.EachPage(func(page gophercloud.Page) (bool, error) {
+ t.Logf("--- Page ---")
+
+ networks, err := networks.ExtractNetworks(page)
+ th.AssertNoErr(t, err)
+
+ for _, n := range networks {
+ t.Logf("Network: ID [%s] Name [%s] Status [%s] Is shared? [%s]",
+ n.ID, n.Name, n.Status, strconv.FormatBool(n.Shared))
+ }
+
+ return true, nil
+ })
+ th.CheckNoErr(t, err)
}
func TestNetworkCRUDOperations(t *testing.T) {
@@ -134,7 +98,7 @@
th.AssertEquals(t, n.Name, "new_network_name")
// Delete network
- err := networks.Delete(Client, networkID)
+ err = networks.Delete(Client, networkID)
th.AssertNoErr(t, err)
}