move unit tests into 'testing' directories
diff --git a/openstack/cdn/v1/base/testing/doc.go b/openstack/cdn/v1/base/testing/doc.go
new file mode 100644
index 0000000..7603f83
--- /dev/null
+++ b/openstack/cdn/v1/base/testing/doc.go
@@ -0,0 +1 @@
+package testing
diff --git a/openstack/cdn/v1/base/testing/fixtures.go b/openstack/cdn/v1/base/testing/fixtures.go
new file mode 100644
index 0000000..f1f4ac0
--- /dev/null
+++ b/openstack/cdn/v1/base/testing/fixtures.go
@@ -0,0 +1,53 @@
+package testing
+
+import (
+ "fmt"
+ "net/http"
+ "testing"
+
+ th "github.com/gophercloud/gophercloud/testhelper"
+ fake "github.com/gophercloud/gophercloud/testhelper/client"
+)
+
+// HandleGetSuccessfully creates an HTTP handler at `/` on the test handler mux
+// that responds with a `Get` response.
+func HandleGetSuccessfully(t *testing.T) {
+ th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ th.TestHeader(t, r, "Accept", "application/json")
+ w.WriteHeader(http.StatusOK)
+ fmt.Fprintf(w, `
+ {
+ "resources": {
+ "rel/cdn": {
+ "href-template": "services{?marker,limit}",
+ "href-vars": {
+ "marker": "param/marker",
+ "limit": "param/limit"
+ },
+ "hints": {
+ "allow": [
+ "GET"
+ ],
+ "formats": {
+ "application/json": {}
+ }
+ }
+ }
+ }
+ }
+ `)
+
+ })
+}
+
+// HandlePingSuccessfully creates an HTTP handler at `/ping` on the test handler
+// mux that responds with a `Ping` response.
+func HandlePingSuccessfully(t *testing.T) {
+ th.Mux.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "GET")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ w.WriteHeader(http.StatusNoContent)
+ })
+}
diff --git a/openstack/cdn/v1/base/testing/requests_test.go b/openstack/cdn/v1/base/testing/requests_test.go
new file mode 100644
index 0000000..cd1209b
--- /dev/null
+++ b/openstack/cdn/v1/base/testing/requests_test.go
@@ -0,0 +1,44 @@
+package testing
+
+import (
+ "testing"
+
+ "github.com/gophercloud/gophercloud/openstack/cdn/v1/base"
+ th "github.com/gophercloud/gophercloud/testhelper"
+ fake "github.com/gophercloud/gophercloud/testhelper/client"
+)
+
+func TestGetHomeDocument(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandleGetSuccessfully(t)
+
+ actual, err := base.Get(fake.ServiceClient()).Extract()
+ th.CheckNoErr(t, err)
+
+ expected := base.HomeDocument{
+ "rel/cdn": map[string]interface{}{
+ "href-template": "services{?marker,limit}",
+ "href-vars": map[string]interface{}{
+ "marker": "param/marker",
+ "limit": "param/limit",
+ },
+ "hints": map[string]interface{}{
+ "allow": []string{"GET"},
+ "formats": map[string]interface{}{
+ "application/json": map[string]interface{}{},
+ },
+ },
+ },
+ }
+ th.CheckDeepEquals(t, expected, *actual)
+}
+
+func TestPing(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ HandlePingSuccessfully(t)
+
+ err := base.Ping(fake.ServiceClient()).ExtractErr()
+ th.CheckNoErr(t, err)
+}