blob: 248ab91a456ae2c9ca2dbb4780f45efe130255ae [file] [log] [blame]
Ash Wilson8fecf332014-10-20 15:18:46 -04001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud/pagination"
9 "github.com/rackspace/gophercloud/rackspace/compute/v2/flavors"
10 th "github.com/rackspace/gophercloud/testhelper"
11)
12
13func TestListFlavors(t *testing.T) {
14 client, err := newClient()
15 th.AssertNoErr(t, err)
16
17 count := 0
18 err = flavors.List(client, nil).EachPage(func(page pagination.Page) (bool, error) {
19 count++
20 t.Logf("-- Page %0d --", count)
21
22 fs, err := flavors.ExtractFlavors(page)
23 th.AssertNoErr(t, err)
24
25 for i, flavor := range fs {
26 t.Logf("[%02d] id=[%s]", i, flavor.ID)
27 t.Logf(" name=[%s]", flavor.Name)
28 t.Logf(" disk=[%d]", flavor.Disk)
29 t.Logf(" RAM=[%d]", flavor.RAM)
30 t.Logf(" rxtx_factor=[%f]", flavor.RxTxFactor)
31 t.Logf(" swap=[%d]", flavor.Swap)
32 t.Logf(" VCPUs=[%d]", flavor.VCPUs)
33 }
34
35 return true, nil
36 })
37 th.AssertNoErr(t, err)
38 if count == 0 {
39 t.Errorf("No flavors listed!")
40 }
41}
42
43func TestGetFlavor(t *testing.T) {
44 client, err := newClient()
45 th.AssertNoErr(t, err)
46
47 options, err := optionsFromEnv()
48 th.AssertNoErr(t, err)
49
50 flavor, err := flavors.Get(client, options.flavorID).Extract()
51 th.AssertNoErr(t, err)
52
Ash Wilsonf595dc42014-10-20 15:24:15 -040053 t.Logf("Requested flavor:")
Ash Wilson8fecf332014-10-20 15:18:46 -040054 t.Logf(" id=[%s]", flavor.ID)
55 t.Logf(" name=[%s]", flavor.Name)
56 t.Logf(" disk=[%d]", flavor.Disk)
57 t.Logf(" RAM=[%d]", flavor.RAM)
58 t.Logf(" rxtx_factor=[%f]", flavor.RxTxFactor)
59 t.Logf(" swap=[%d]", flavor.Swap)
60 t.Logf(" VCPUs=[%d]", flavor.VCPUs)
61}