Reorganized volumes and volumeattach to move fixtures to subpackage
diff --git a/openstack/compute/v2/extensions/volumeattach/requests_test.go b/openstack/compute/v2/extensions/volumeattach/requests_test.go
index e17f7e0..b0a765b 100644
--- a/openstack/compute/v2/extensions/volumeattach/requests_test.go
+++ b/openstack/compute/v2/extensions/volumeattach/requests_test.go
@@ -3,15 +3,44 @@
import (
"testing"
+ fixtures "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/volumeattach/testing"
"github.com/rackspace/gophercloud/pagination"
th "github.com/rackspace/gophercloud/testhelper"
"github.com/rackspace/gophercloud/testhelper/client"
)
+// FirstVolumeAttachment is the first result in ListOutput.
+var FirstVolumeAttachment = VolumeAttachment{
+ Device: "/dev/vdd",
+ ID: "a26887c6-c47b-4654-abb5-dfadf7d3f803",
+ ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
+ VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f803",
+}
+
+// SecondVolumeAttachment is the first result in ListOutput.
+var SecondVolumeAttachment = VolumeAttachment{
+ Device: "/dev/vdc",
+ ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
+ ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
+ VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
+}
+
+// ExpectedVolumeAttachmentSlide is the slice of results that should be parsed
+// from ListOutput, in the expected order.
+var ExpectedVolumeAttachmentSlice = []VolumeAttachment{FirstVolumeAttachment, SecondVolumeAttachment}
+
+//CreatedVolumeAttachment is the parsed result from CreatedOutput.
+var CreatedVolumeAttachment = VolumeAttachment{
+ Device: "/dev/vdc",
+ ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
+ ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
+ VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
+}
+
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- HandleListSuccessfully(t)
+ fixtures.HandleListSuccessfully(t)
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
count := 0
@@ -30,7 +59,7 @@
func TestCreate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- HandleCreateSuccessfully(t)
+ fixtures.HandleCreateSuccessfully(t)
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
actual, err := Create(client.ServiceClient(), serverId, CreateOpts{
@@ -44,7 +73,7 @@
func TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- HandleGetSuccessfully(t)
+ fixtures.HandleGetSuccessfully(t)
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
@@ -56,7 +85,7 @@
func TestDelete(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
- HandleDeleteSuccessfully(t)
+ fixtures.HandleDeleteSuccessfully(t)
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
diff --git a/openstack/compute/v2/extensions/volumeattach/testing/doc.go b/openstack/compute/v2/extensions/volumeattach/testing/doc.go
new file mode 100644
index 0000000..183391a
--- /dev/null
+++ b/openstack/compute/v2/extensions/volumeattach/testing/doc.go
@@ -0,0 +1,7 @@
+/*
+This is package created is to hold fixtures (which imports testing),
+so that importing volumeattach package does not inadvertently import testing into production code
+More information here:
+https://github.com/rackspace/gophercloud/issues/473
+*/
+package testing
diff --git a/openstack/compute/v2/extensions/volumeattach/fixtures.go b/openstack/compute/v2/extensions/volumeattach/testing/fixtures.go
similarity index 74%
rename from openstack/compute/v2/extensions/volumeattach/fixtures.go
rename to openstack/compute/v2/extensions/volumeattach/testing/fixtures.go
index a7f03b3..c469bfb 100644
--- a/openstack/compute/v2/extensions/volumeattach/fixtures.go
+++ b/openstack/compute/v2/extensions/volumeattach/testing/fixtures.go
@@ -1,6 +1,6 @@
// +build fixtures
-package volumeattach
+package testing
import (
"fmt"
@@ -55,34 +55,6 @@
}
`
-// FirstVolumeAttachment is the first result in ListOutput.
-var FirstVolumeAttachment = VolumeAttachment{
- Device: "/dev/vdd",
- ID: "a26887c6-c47b-4654-abb5-dfadf7d3f803",
- ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f803",
-}
-
-// SecondVolumeAttachment is the first result in ListOutput.
-var SecondVolumeAttachment = VolumeAttachment{
- Device: "/dev/vdc",
- ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
- ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
-}
-
-// ExpectedVolumeAttachmentSlide is the slice of results that should be parsed
-// from ListOutput, in the expected order.
-var ExpectedVolumeAttachmentSlice = []VolumeAttachment{FirstVolumeAttachment, SecondVolumeAttachment}
-
-// CreatedVolumeAttachment is the parsed result from CreatedOutput.
-var CreatedVolumeAttachment = VolumeAttachment{
- Device: "/dev/vdc",
- ID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
- ServerID: "4d8c3732-a248-40ed-bebc-539a6ffd25c0",
- VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
-}
-
// HandleListSuccessfully configures the test server to respond to a List request.
func HandleListSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/servers/4d8c3732-a248-40ed-bebc-539a6ffd25c0/os-volume_attachments", func(w http.ResponseWriter, r *http.Request) {