blob: 409550cf0c76394a606b4609010a65043cf52eef [file] [log] [blame]
Jamie Hannaford4721abc2014-09-16 16:29:04 +02001// +build acceptance networking
2
3package v2
4
5import (
6 "testing"
7
Joe Topjian7c8dd022016-09-01 12:02:04 -06008 "github.com/gophercloud/gophercloud/acceptance/clients"
Jon Perritt27249f42016-02-18 10:35:59 -06009 "github.com/gophercloud/gophercloud/openstack/networking/v2/apiversions"
Jamie Hannaford4721abc2014-09-16 16:29:04 +020010)
11
Joe Topjian7c8dd022016-09-01 12:02:04 -060012func 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 Hannaford4721abc2014-09-16 16:29:04 +020017
Joe Topjian7c8dd022016-09-01 12:02:04 -060018 allPages, err := apiversions.ListVersions(client).AllPages()
19 if err != nil {
20 t.Fatalf("Unable to list api versions: %v", err)
21 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020022
Joe Topjian7c8dd022016-09-01 12:02:04 -060023 allAPIVersions, err := apiversions.ExtractAPIVersions(allPages)
24 if err != nil {
25 t.Fatalf("Unable to extract api versions: %v", err)
26 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020027
Joe Topjian7c8dd022016-09-01 12:02:04 -060028 for _, apiVersion := range allAPIVersions {
29 PrintAPIVersion(t, &apiVersion)
30 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020031}
32
Joe Topjian7c8dd022016-09-01 12:02:04 -060033func 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 Hannaford4721abc2014-09-16 16:29:04 +020038
Joe Topjian7c8dd022016-09-01 12:02:04 -060039 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 Hannaford4721abc2014-09-16 16:29:04 +020043
Joe Topjian7c8dd022016-09-01 12:02:04 -060044 allVersionResources, err := apiversions.ExtractVersionResources(allPages)
45 if err != nil {
46 t.Fatalf("Unable to extract version resources: %v", err)
47 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020048
Joe Topjian7c8dd022016-09-01 12:02:04 -060049 for _, versionResource := range allVersionResources {
50 PrintVersionResource(t, &versionResource)
51 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020052}