blob: 6f6490ea0a7e9f59615447729423a972c285aaef [file] [log] [blame]
// +build acceptance compute flavors
package v2
import (
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
)
func TestFlavorsList(t *testing.T) {
client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
allPages, err := flavors.ListDetail(client, nil).AllPages()
if err != nil {
t.Fatalf("Unable to retrieve flavors: %v", err)
}
allFlavors, err := flavors.ExtractFlavors(allPages)
if err != nil {
t.Fatalf("Unable to extract flavor results: %v", err)
}
for _, flavor := range allFlavors {
PrintFlavor(t, &flavor)
}
}
func TestFlavorsGet(t *testing.T) {
client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
choices, err :=clients.AcceptanceTestChoicesFromEnv()
if err != nil {
t.Fatal(err)
}
flavor, err := flavors.Get(client, choices.FlavorID).Extract()
if err != nil {
t.Fatalf("Unable to get flavor information: %v", err)
}
PrintFlavor(t, flavor)
}