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/images_test.go b/acceptance/openstack/compute/v2/images_test.go
index 15af9af..53291dd 100644
--- a/acceptance/openstack/compute/v2/images_test.go
+++ b/acceptance/openstack/compute/v2/images_test.go
@@ -5,11 +5,12 @@
import (
"testing"
+ "github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/openstack/compute/v2/images"
)
func TestImagesList(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 _, image := range allImages {
- printImage(t, image)
+ PrintImage(t, image)
}
}
func TestImagesGet(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,17 +46,5 @@
t.Fatalf("Unable to get image information: %v", err)
}
- printImage(t, *image)
-}
-
-func printImage(t *testing.T, image images.Image) {
- t.Logf("ID: %s", image.ID)
- t.Logf("Name: %s", image.Name)
- t.Logf("MinDisk: %d", image.MinDisk)
- t.Logf("MinRAM: %d", image.MinRAM)
- t.Logf("Status: %s", image.Status)
- t.Logf("Progress: %d", image.Progress)
- t.Logf("Metadata: %#v", image.Metadata)
- t.Logf("Created: %s", image.Created)
- t.Logf("Updated: %s", image.Updated)
+ PrintImage(t, *image)
}