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 | |
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/networking/v2/apiversions" |
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 TestAPIVersionsList(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 := apiversions.ListVersions(client).AllPages() |
| 20 | if err != nil { |
| 21 | t.Fatalf("Unable to list api versions: %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 | allAPIVersions, err := apiversions.ExtractAPIVersions(allPages) |
| 25 | if err != nil { |
| 26 | t.Fatalf("Unable to extract api versions: %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 _, apiVersion := range allAPIVersions { |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 30 | tools.PrintResource(t, apiVersion) |
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 TestAPIResourcesList(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 | allPages, err := apiversions.ListVersionResources(client, "v2.0").AllPages() |
| 41 | if err != nil { |
| 42 | t.Fatalf("Unable to list api version reosources: %v", err) |
| 43 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 44 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 45 | allVersionResources, err := apiversions.ExtractVersionResources(allPages) |
| 46 | if err != nil { |
| 47 | t.Fatalf("Unable to extract version resources: %v", err) |
| 48 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 49 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 50 | for _, versionResource := range allVersionResources { |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 51 | tools.PrintResource(t, versionResource) |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame] | 52 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 53 | } |