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/extensions" |
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 TestListExts(t *testing.T) { |
| 14 | Setup(t) |
| 15 | defer Teardown() |
| 16 | |
| 17 | pager := extensions.List(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 | exts, err := extensions.ExtractExtensions(page) |
| 22 | th.AssertNoErr(t, err) |
| 23 | |
| 24 | for _, ext := range exts { |
| 25 | t.Logf("Extension: Name [%s] Description [%s]", ext.Name, ext.Description) |
| 26 | } |
| 27 | |
| 28 | return true, nil |
| 29 | }) |
| 30 | th.CheckNoErr(t, err) |
| 31 | } |
| 32 | |
| 33 | func TestGetExt(t *testing.T) { |
| 34 | Setup(t) |
| 35 | defer Teardown() |
| 36 | |
Jamie Hannaford | d903642 | 2014-09-23 17:50:24 +0200 | [diff] [blame] | 37 | ext, err := extensions.Get(Client, "service-type").Extract() |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 38 | th.AssertNoErr(t, err) |
| 39 | |
| 40 | th.AssertEquals(t, ext.Updated, "2013-01-20T00:00:00-00:00") |
| 41 | th.AssertEquals(t, ext.Name, "Neutron Service Type Management") |
| 42 | th.AssertEquals(t, ext.Namespace, "http://docs.openstack.org/ext/neutron/service-type/api/v1.0") |
| 43 | th.AssertEquals(t, ext.Alias, "service-type") |
| 44 | th.AssertEquals(t, ext.Description, "API for retrieving service providers for Neutron advanced services") |
| 45 | } |