| // +build acceptance compute flavors |
| |
| package v2 |
| |
| import ( |
| "testing" |
| |
| "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/clients" |
| "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/tools" |
| "gerrit.mcp.mirantis.net/debian/gophercloud.git/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 { |
| tools.PrintResource(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) |
| } |
| |
| tools.PrintResource(t, flavor) |
| } |