Compute Acceptance Test Changes (#33)
This commit makes more changes to the compute acceptance tests:
* Makes all reusable functions exportable so other APIs can use them.
* Centralizes client initialization and environment variable checks.
diff --git a/acceptance/openstack/compute/v2/flavors_test.go b/acceptance/openstack/compute/v2/flavors_test.go
index bc6a2c7..6f6490e 100644
--- a/acceptance/openstack/compute/v2/flavors_test.go
+++ b/acceptance/openstack/compute/v2/flavors_test.go
@@ -5,11 +5,12 @@
import (
"testing"
+ "github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
)
func TestFlavorsList(t *testing.T) {
- client, err := newClient()
+ client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
@@ -25,17 +26,17 @@
}
for _, flavor := range allFlavors {
- printFlavor(t, &flavor)
+ PrintFlavor(t, &flavor)
}
}
func TestFlavorsGet(t *testing.T) {
- client, err := newClient()
+ client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := ComputeChoicesFromEnv()
+ choices, err :=clients.AcceptanceTestChoicesFromEnv()
if err != nil {
t.Fatal(err)
}
@@ -45,14 +46,5 @@
t.Fatalf("Unable to get flavor information: %v", err)
}
- printFlavor(t, flavor)
-}
-
-func printFlavor(t *testing.T, flavor *flavors.Flavor) {
- t.Logf("ID: %s", flavor.ID)
- t.Logf("Name: %s", flavor.Name)
- t.Logf("RAM: %d", flavor.RAM)
- t.Logf("Disk: %d", flavor.Disk)
- t.Logf("Swap: %d", flavor.Swap)
- t.Logf("RxTxFactor: %f", flavor.RxTxFactor)
+ PrintFlavor(t, flavor)
}