blob: f26cff0140cd85859f04ecd5c62d77865a5a822b [file] [log] [blame]
Jon Perrittdc471802015-01-22 08:51:31 -07001// +build acceptance
2
3package v1
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud"
9 os "github.com/rackspace/gophercloud/openstack/cdn/v1/flavors"
10 "github.com/rackspace/gophercloud/pagination"
11 "github.com/rackspace/gophercloud/rackspace/cdn/v1/flavors"
12 th "github.com/rackspace/gophercloud/testhelper"
13)
14
15func TestFlavor(t *testing.T) {
16 client := newClient(t)
17
18 t.Log("Listing Flavors")
19 id := testFlavorsList(t, client)
20
21 t.Log("Retrieving Flavor")
22 testFlavorGet(t, client, id)
23}
24
25func testFlavorsList(t *testing.T, client *gophercloud.ServiceClient) string {
26 var id string
27 err := flavors.List(client).EachPage(func(page pagination.Page) (bool, error) {
28 flavorList, err := os.ExtractFlavors(page)
29 th.AssertNoErr(t, err)
30
31 for _, flavor := range flavorList {
32 t.Logf("Listing flavor: ID [%s] Providers [%+v]", flavor.ID, flavor.Providers)
33 id = flavor.ID
34 }
35
36 return true, nil
37 })
38
39 th.AssertNoErr(t, err)
40 return id
41}
42
43func testFlavorGet(t *testing.T, client *gophercloud.ServiceClient, id string) {
44 flavor, err := flavors.Get(client, id).Extract()
45 th.AssertNoErr(t, err)
46 t.Logf("Retrieved Flavor: %+v", *flavor)
47}