Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 1 | // +build acceptance networking |
| 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 8 | "github.com/rackspace/gophercloud/openstack/networking/v2/apiversions" |
Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame] | 9 | "github.com/rackspace/gophercloud/pagination" |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 10 | th "github.com/rackspace/gophercloud/testhelper" |
| 11 | ) |
| 12 | |
| 13 | func TestListAPIVersions(t *testing.T) { |
| 14 | Setup(t) |
| 15 | defer Teardown() |
| 16 | |
| 17 | pager := apiversions.ListVersions(Client) |
Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame] | 18 | err := pager.EachPage(func(page pagination.Page) (bool, error) { |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 19 | t.Logf("--- Page ---") |
| 20 | |
| 21 | versions, err := apiversions.ExtractAPIVersions(page) |
| 22 | th.AssertNoErr(t, err) |
| 23 | |
| 24 | for _, v := range versions { |
| 25 | t.Logf("API Version: ID [%s] Status [%s]", v.ID, v.Status) |
| 26 | } |
| 27 | |
| 28 | return true, nil |
| 29 | }) |
| 30 | th.CheckNoErr(t, err) |
| 31 | } |
| 32 | |
| 33 | func TestListAPIResources(t *testing.T) { |
| 34 | Setup(t) |
| 35 | defer Teardown() |
| 36 | |
| 37 | pager := apiversions.ListVersionResources(Client, "v2.0") |
Jamie Hannaford | f0c615b | 2014-09-17 10:56:52 +0200 | [diff] [blame] | 38 | err := pager.EachPage(func(page pagination.Page) (bool, error) { |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 39 | t.Logf("--- Page ---") |
| 40 | |
| 41 | vrs, err := apiversions.ExtractVersionResources(page) |
| 42 | th.AssertNoErr(t, err) |
| 43 | |
| 44 | for _, vr := range vrs { |
| 45 | t.Logf("Network: Name [%s] Collection [%s]", vr.Name, vr.Collection) |
| 46 | } |
| 47 | |
| 48 | return true, nil |
| 49 | }) |
| 50 | th.CheckNoErr(t, err) |
| 51 | } |