rax cdn unit tests
diff --git a/rackspace/objectstorage/v1/accounts/delegate_test.go b/rackspace/objectstorage/v1/accounts/delegate_test.go
index 15a21ae..bfe3f95 100644
--- a/rackspace/objectstorage/v1/accounts/delegate_test.go
+++ b/rackspace/objectstorage/v1/accounts/delegate_test.go
@@ -15,9 +15,7 @@
options := &UpdateOpts{Metadata: map[string]string{"gophercloud-test": "accounts"}}
_, err := Update(fake.ServiceClient(), options).ExtractHeaders()
- if err != nil {
- t.Fatalf("Unable to update account: %v", err)
- }
+ th.CheckNoErr(t, err)
}
func TestUpdateAccounts(t *testing.T) {
@@ -27,8 +25,6 @@
expected := map[string]string{"Foo": "bar"}
actual, err := Get(fake.ServiceClient()).ExtractMetadata()
- if err != nil {
- t.Fatalf("Unable to get account metadata: %v", err)
- }
+ th.CheckNoErr(t, err)
th.CheckDeepEquals(t, expected, actual)
}
diff --git a/rackspace/objectstorage/v1/cdncontainers/delegate.go b/rackspace/objectstorage/v1/cdncontainers/delegate.go
index 40c4ed1..f5e8cdd 100644
--- a/rackspace/objectstorage/v1/cdncontainers/delegate.go
+++ b/rackspace/objectstorage/v1/cdncontainers/delegate.go
@@ -33,7 +33,7 @@
// List is a function that retrieves containers associated with the account as
// well as account metadata. It returns a pager which can be iterated with the
// EachPage function.
-func List(c *gophercloud.ServiceClient, opts *ListOpts) pagination.Pager {
+func List(c *gophercloud.ServiceClient, opts os.ListOptsBuilder) pagination.Pager {
return os.List(c, opts)
}
diff --git a/rackspace/objectstorage/v1/cdncontainers/delegate_test.go b/rackspace/objectstorage/v1/cdncontainers/delegate_test.go
index 1b2124d..a294f7e 100644
--- a/rackspace/objectstorage/v1/cdncontainers/delegate_test.go
+++ b/rackspace/objectstorage/v1/cdncontainers/delegate_test.go
@@ -1 +1,50 @@
package cdncontainers
+
+import (
+ "testing"
+
+ os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/containers"
+ "github.com/rackspace/gophercloud/pagination"
+ th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
+)
+
+func TestListCDNContainers(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ os.HandleListContainerNamesSuccessfully(t)
+
+ count := 0
+ err := List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
+ count++
+ actual, err := ExtractNames(page)
+ th.AssertNoErr(t, err)
+
+ th.CheckDeepEquals(t, os.ExpectedListNames, actual)
+
+ return true, nil
+ })
+ th.AssertNoErr(t, err)
+ th.CheckEquals(t, count, 1)
+}
+
+func TestGetCDNContainer(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ os.HandleGetContainerSuccessfully(t)
+
+ _, err := Get(fake.ServiceClient(), "testContainer").ExtractMetadata()
+ th.CheckNoErr(t, err)
+
+}
+
+func TestUpdateCDNContainer(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ os.HandleUpdateContainerSuccessfully(t)
+
+ options := &UpdateOpts{TTL: 3600}
+ _, err := Update(fake.ServiceClient(), "testContainer", options).ExtractHeaders()
+ th.CheckNoErr(t, err)
+
+}
diff --git a/rackspace/objectstorage/v1/cdncontainers/requests_test.go b/rackspace/objectstorage/v1/cdncontainers/requests_test.go
index 1b2124d..04ee814 100644
--- a/rackspace/objectstorage/v1/cdncontainers/requests_test.go
+++ b/rackspace/objectstorage/v1/cdncontainers/requests_test.go
@@ -1 +1,29 @@
package cdncontainers
+
+import (
+ "net/http"
+ "testing"
+
+ th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
+)
+
+func TestEnableCDNContainer(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
+ th.TestMethod(t, r, "PUT")
+ th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
+ th.TestHeader(t, r, "Accept", "application/json")
+
+ w.Header().Add("X-Ttl", "259200")
+ w.Header().Add("X-Cdn-Enabled", "True")
+ w.WriteHeader(http.StatusNoContent)
+ })
+
+ options := &EnableOpts{CDNEnabled: true, TTL: 259200}
+ actual, err := Enable(fake.ServiceClient(), "testContainer", options).ExtractHeaders()
+ th.AssertNoErr(t, err)
+ th.CheckEquals(t, actual["X-Ttl"][0], "259200")
+ th.CheckEquals(t, actual["X-Cdn-Enabled"][0], "True")
+}
diff --git a/rackspace/objectstorage/v1/cdncontainers/urls.go b/rackspace/objectstorage/v1/cdncontainers/urls.go
index abcf238..80653f2 100644
--- a/rackspace/objectstorage/v1/cdncontainers/urls.go
+++ b/rackspace/objectstorage/v1/cdncontainers/urls.go
@@ -2,18 +2,6 @@
import "github.com/rackspace/gophercloud"
-func listURL(c *gophercloud.ServiceClient) string {
- return c.Endpoint
-}
-
func enableURL(c *gophercloud.ServiceClient, containerName string) string {
return c.ServiceURL(containerName)
}
-
-func getURL(c *gophercloud.ServiceClient, containerName string) string {
- return c.ServiceURL(containerName)
-}
-
-func updateURL(c *gophercloud.ServiceClient, containerName string) string {
- return c.ServiceURL(containerName)
-}
diff --git a/rackspace/objectstorage/v1/cdncontainers/urls_test.go b/rackspace/objectstorage/v1/cdncontainers/urls_test.go
index 8acd01b..aa5bfe6 100644
--- a/rackspace/objectstorage/v1/cdncontainers/urls_test.go
+++ b/rackspace/objectstorage/v1/cdncontainers/urls_test.go
@@ -13,26 +13,8 @@
return &gophercloud.ServiceClient{Endpoint: endpoint}
}
-func TestListURL(t *testing.T) {
- actual := listURL(endpointClient())
- expected := endpoint
- th.CheckEquals(t, expected, actual)
-}
-
func TestEnableURL(t *testing.T) {
actual := enableURL(endpointClient(), "foo")
expected := endpoint + "foo"
th.CheckEquals(t, expected, actual)
}
-
-func TestGetURL(t *testing.T) {
- actual := getURL(endpointClient(), "foo")
- expected := endpoint + "foo"
- th.CheckEquals(t, expected, actual)
-}
-
-func TestUpdateURL(t *testing.T) {
- actual := updateURL(endpointClient(), "foo")
- expected := endpoint + "foo"
- th.CheckEquals(t, expected, actual)
-}
diff --git a/rackspace/objectstorage/v1/cdnobjects/delegate_test.go b/rackspace/objectstorage/v1/cdnobjects/delegate_test.go
index 03d45e5..15b716d 100644
--- a/rackspace/objectstorage/v1/cdnobjects/delegate_test.go
+++ b/rackspace/objectstorage/v1/cdnobjects/delegate_test.go
@@ -1 +1,19 @@
package cdnobjects
+
+import (
+ "testing"
+
+ os "github.com/rackspace/gophercloud/openstack/objectstorage/v1/objects"
+ th "github.com/rackspace/gophercloud/testhelper"
+ fake "github.com/rackspace/gophercloud/testhelper/client"
+)
+
+func TestDeleteCDNObject(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+ os.HandleDeleteObjectSuccessfully(t)
+
+ _, err := Delete(fake.ServiceClient(), "testContainer", "testObject", nil).ExtractHeaders()
+ th.AssertNoErr(t, err)
+
+}