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 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 8 | "github.com/gophercloud/gophercloud/acceptance/clients" |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 9 | "github.com/gophercloud/gophercloud/openstack/networking/v2/apiversions" |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 10 | ) |
| 11 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 12 | func TestAPIVersionsList(t *testing.T) { |
| 13 | client, err := clients.NewNetworkV2Client() |
| 14 | if err != nil { |
| 15 | t.Fatalf("Unable to create a network client: %v", err) |
| 16 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 17 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 18 | allPages, err := apiversions.ListVersions(client).AllPages() |
| 19 | if err != nil { |
| 20 | t.Fatalf("Unable to list api versions: %v", err) |
| 21 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 22 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 23 | allAPIVersions, err := apiversions.ExtractAPIVersions(allPages) |
| 24 | if err != nil { |
| 25 | t.Fatalf("Unable to extract api versions: %v", err) |
| 26 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 27 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 28 | for _, apiVersion := range allAPIVersions { |
| 29 | PrintAPIVersion(t, &apiVersion) |
| 30 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 31 | } |
| 32 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 33 | func TestAPIResourcesList(t *testing.T) { |
| 34 | client, err := clients.NewNetworkV2Client() |
| 35 | if err != nil { |
| 36 | t.Fatalf("Unable to create a network client: %v", err) |
| 37 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 38 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 39 | allPages, err := apiversions.ListVersionResources(client, "v2.0").AllPages() |
| 40 | if err != nil { |
| 41 | t.Fatalf("Unable to list api version reosources: %v", err) |
| 42 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 43 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 44 | allVersionResources, err := apiversions.ExtractVersionResources(allPages) |
| 45 | if err != nil { |
| 46 | t.Fatalf("Unable to extract version resources: %v", err) |
| 47 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 48 | |
Joe Topjian | 7c8dd02 | 2016-09-01 12:02:04 -0600 | [diff] [blame^] | 49 | for _, versionResource := range allVersionResources { |
| 50 | PrintVersionResource(t, &versionResource) |
| 51 | } |
Jamie Hannaford | 4721abc | 2014-09-16 16:29:04 +0200 | [diff] [blame] | 52 | } |