blob: c6f8f261b35ea8f420510d1ccc58708d8ed39567 [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"
Joe Topjian66a046c2017-01-19 22:07:26 -07009 "github.com/gophercloud/gophercloud/acceptance/tools"
Jon Perritt27249f42016-02-18 10:35:59 -060010 "github.com/gophercloud/gophercloud/openstack/networking/v2/apiversions"
Jamie Hannaford4721abc2014-09-16 16:29:04 +020011)
12
Joe Topjian7c8dd022016-09-01 12:02:04 -060013func 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 Hannaford4721abc2014-09-16 16:29:04 +020018
Joe Topjian7c8dd022016-09-01 12:02:04 -060019 allPages, err := apiversions.ListVersions(client).AllPages()
20 if err != nil {
21 t.Fatalf("Unable to list api versions: %v", err)
22 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020023
Joe Topjian7c8dd022016-09-01 12:02:04 -060024 allAPIVersions, err := apiversions.ExtractAPIVersions(allPages)
25 if err != nil {
26 t.Fatalf("Unable to extract api versions: %v", err)
27 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020028
Joe Topjian7c8dd022016-09-01 12:02:04 -060029 for _, apiVersion := range allAPIVersions {
Joe Topjian66a046c2017-01-19 22:07:26 -070030 tools.PrintResource(t, apiVersion)
Joe Topjian7c8dd022016-09-01 12:02:04 -060031 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020032}
33
Joe Topjian7c8dd022016-09-01 12:02:04 -060034func 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 Hannaford4721abc2014-09-16 16:29:04 +020039
Joe Topjian7c8dd022016-09-01 12:02:04 -060040 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 Hannaford4721abc2014-09-16 16:29:04 +020044
Joe Topjian7c8dd022016-09-01 12:02:04 -060045 allVersionResources, err := apiversions.ExtractVersionResources(allPages)
46 if err != nil {
47 t.Fatalf("Unable to extract version resources: %v", err)
48 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020049
Joe Topjian7c8dd022016-09-01 12:02:04 -060050 for _, versionResource := range allVersionResources {
Joe Topjian66a046c2017-01-19 22:07:26 -070051 tools.PrintResource(t, versionResource)
Joe Topjian7c8dd022016-09-01 12:02:04 -060052 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020053}