Acceptance tests for flavor operations.
diff --git a/acceptance/rackspace/compute/v2/compute_test.go b/acceptance/rackspace/compute/v2/compute_test.go
new file mode 100644
index 0000000..3419c10
--- /dev/null
+++ b/acceptance/rackspace/compute/v2/compute_test.go
@@ -0,0 +1,58 @@
+// +build acceptance
+
+package v2
+
+import (
+ "errors"
+ "os"
+
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/rackspace"
+)
+
+func newClient() (*gophercloud.ServiceClient, error) {
+ // Obtain credentials from the environment.
+ options := gophercloud.AuthOptions{
+ Username: os.Getenv("RS_USERNAME"),
+ APIKey: os.Getenv("RS_APIKEY"),
+ }
+ region := os.Getenv("RS_REGION")
+
+ if options.Username == "" {
+ return nil, errors.New("Please provide a Rackspace username as RS_USERNAME.")
+ }
+ if options.APIKey == "" {
+ return nil, errors.New("Please provide a Rackspace API key as RS_APIKEY.")
+ }
+ if region == "" {
+ return nil, errors.New("Please provide a Rackspace region as RS_REGION.")
+ }
+
+ client, err := rackspace.AuthenticatedClient(options)
+ if err != nil {
+ return nil, err
+ }
+
+ return rackspace.NewComputeV2(client, gophercloud.EndpointOpts{
+ Region: region,
+ })
+}
+
+type serverOpts struct {
+ imageID string
+ flavorID string
+}
+
+func optionsFromEnv() (*serverOpts, error) {
+ options := &serverOpts{
+ imageID: os.Getenv("RS_IMAGE_ID"),
+ flavorID: os.Getenv("RS_FLAVOR_ID"),
+ }
+ if options.imageID == "" {
+ return nil, errors.New("Please provide a valid Rackspace image ID as RS_IMAGE_ID")
+ }
+ if options.flavorID == "" {
+ return nil, errors.New("Please provide a valid Rackspace flavor ID as RS_FLAVOR_ID")
+ }
+ return options, nil
+}
diff --git a/acceptance/rackspace/compute/v2/flavors_test.go b/acceptance/rackspace/compute/v2/flavors_test.go
new file mode 100644
index 0000000..ff60f25
--- /dev/null
+++ b/acceptance/rackspace/compute/v2/flavors_test.go
@@ -0,0 +1,60 @@
+// +build acceptance
+
+package v2
+
+import (
+ "testing"
+
+ "github.com/rackspace/gophercloud/pagination"
+ "github.com/rackspace/gophercloud/rackspace/compute/v2/flavors"
+ th "github.com/rackspace/gophercloud/testhelper"
+)
+
+func TestListFlavors(t *testing.T) {
+ client, err := newClient()
+ th.AssertNoErr(t, err)
+
+ count := 0
+ err = flavors.List(client, nil).EachPage(func(page pagination.Page) (bool, error) {
+ count++
+ t.Logf("-- Page %0d --", count)
+
+ fs, err := flavors.ExtractFlavors(page)
+ th.AssertNoErr(t, err)
+
+ for i, flavor := range fs {
+ t.Logf("[%02d] id=[%s]", i, flavor.ID)
+ t.Logf(" name=[%s]", flavor.Name)
+ t.Logf(" disk=[%d]", flavor.Disk)
+ t.Logf(" RAM=[%d]", flavor.RAM)
+ t.Logf(" rxtx_factor=[%f]", flavor.RxTxFactor)
+ t.Logf(" swap=[%d]", flavor.Swap)
+ t.Logf(" VCPUs=[%d]", flavor.VCPUs)
+ }
+
+ return true, nil
+ })
+ th.AssertNoErr(t, err)
+ if count == 0 {
+ t.Errorf("No flavors listed!")
+ }
+}
+
+func TestGetFlavor(t *testing.T) {
+ client, err := newClient()
+ th.AssertNoErr(t, err)
+
+ options, err := optionsFromEnv()
+ th.AssertNoErr(t, err)
+
+ flavor, err := flavors.Get(client, options.flavorID).Extract()
+ th.AssertNoErr(t, err)
+
+ t.Logf(" id=[%s]", flavor.ID)
+ t.Logf(" name=[%s]", flavor.Name)
+ t.Logf(" disk=[%d]", flavor.Disk)
+ t.Logf(" RAM=[%d]", flavor.RAM)
+ t.Logf(" rxtx_factor=[%f]", flavor.RxTxFactor)
+ t.Logf(" swap=[%d]", flavor.Swap)
+ t.Logf(" VCPUs=[%d]", flavor.VCPUs)
+}
diff --git a/acceptance/rackspace/compute/v2/pkg.go b/acceptance/rackspace/compute/v2/pkg.go
new file mode 100644
index 0000000..5ec3cc8
--- /dev/null
+++ b/acceptance/rackspace/compute/v2/pkg.go
@@ -0,0 +1 @@
+package v2