blob: f57d86a4d46a2c6c61ed33756c0be0ad52908f50 [file] [log] [blame]
Jon Perritt0eeeb0c2015-03-17 22:38:31 -06001// +build acceptance
2
3package v3
4
5import (
6 "fmt"
7 "testing"
8
9 "github.com/rackspace/gophercloud"
10 "github.com/rackspace/gophercloud/rackspace/rackconnect/v3/cloudnetworks"
11 th "github.com/rackspace/gophercloud/testhelper"
12)
13
14func TestCloudNetworks(t *testing.T) {
15 c := newClient(t)
16 cnID := testList(t, c)
17 testGet(t, c, cnID)
18}
19
20func testList(t *testing.T, c *gophercloud.ServiceClient) string {
21 allPages, err := cloudnetworks.List(c).AllPages()
22 th.AssertNoErr(t, err)
23 allcn, err := cloudnetworks.ExtractCloudNetworks(allPages)
24 fmt.Printf("Listing all cloud networks: %+v\n", allcn)
25 var cnID string
26 if len(allcn) > 0 {
27 cnID = allcn[0].ID
28 }
29 return cnID
30}
31
32func testGet(t *testing.T, c *gophercloud.ServiceClient, id string) {
33 cn, err := cloudnetworks.Get(c, id).Extract()
34 th.AssertNoErr(t, err)
35 fmt.Printf("Retrieved cloud network: %+v\n", cn)
36}