Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 1 | // +build acceptance networking extensions |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Krzysztof Szukiełojć | 24a29ce | 2017-05-07 14:24:02 +0200 | [diff] [blame] | 8 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/clients" |
| 9 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/tools" |
| 10 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/common/extensions" |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 11 | ) |
| 12 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 13 | func TestExtensionsList(t *testing.T) { |
| 14 | client, err := clients.NewNetworkV2Client() |
| 15 | if err != nil { |
| 16 | t.Fatalf("Unable to create a network client: %v", err) |
| 17 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 18 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 19 | allPages, err := extensions.List(client).AllPages() |
| 20 | if err != nil { |
| 21 | t.Fatalf("Unable to list extensions: %v", err) |
| 22 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 23 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 24 | allExtensions, err := extensions.ExtractExtensions(allPages) |
| 25 | if err != nil { |
| 26 | t.Fatalf("Unable to extract extensions: %v", err) |
| 27 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 28 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 29 | for _, extension := range allExtensions { |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 30 | tools.PrintResource(t, extension) |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 31 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 32 | } |
| 33 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 34 | func TestExtensionGet(t *testing.T) { |
| 35 | client, err := clients.NewNetworkV2Client() |
| 36 | if err != nil { |
| 37 | t.Fatalf("Unable to create a network client: %v", err) |
| 38 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 39 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 40 | extension, err := extensions.Get(client, "router").Extract() |
| 41 | if err != nil { |
| 42 | t.Fatalf("Unable to get extension port-security: %v", err) |
| 43 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 44 | |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 45 | tools.PrintResource(t, extension) |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 46 | } |