Merge pull request #343 from jrperritt/cdn-openstack-rackspace
Minor fixes to Cdn openstack rackspace
diff --git a/openstack/cdn/v1/flavors/fixtures.go b/openstack/cdn/v1/flavors/fixtures.go
index b86c760..f413b6b 100644
--- a/openstack/cdn/v1/flavors/fixtures.go
+++ b/openstack/cdn/v1/flavors/fixtures.go
@@ -28,7 +28,7 @@
"provider": "Fastly",
"links": [
{
- "href": "http: //www.fastly.com",
+ "href": "http://www.fastly.com",
"rel": "provider_url"
}
]
diff --git a/openstack/cdn/v1/flavors/requests_test.go b/openstack/cdn/v1/flavors/requests_test.go
index 2fafb36..7ddf1b1 100644
--- a/openstack/cdn/v1/flavors/requests_test.go
+++ b/openstack/cdn/v1/flavors/requests_test.go
@@ -33,7 +33,7 @@
Provider: "Fastly",
Links: []gophercloud.Link{
gophercloud.Link{
- Href: "http: //www.fastly.com",
+ Href: "http://www.fastly.com",
Rel: "provider_url",
},
},
@@ -53,10 +53,7 @@
return true, nil
})
th.AssertNoErr(t, err)
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
+ th.CheckEquals(t, 1, count)
}
func TestGet(t *testing.T) {
diff --git a/openstack/cdn/v1/services/requests.go b/openstack/cdn/v1/services/requests.go
index f88df19..646f63e 100644
--- a/openstack/cdn/v1/services/requests.go
+++ b/openstack/cdn/v1/services/requests.go
@@ -1,6 +1,7 @@
package services
import (
+ "fmt"
"strings"
"github.com/racker/perigee"
@@ -249,6 +250,9 @@
s := make([]map[string]interface{}, len(opts))
for i, opt := range opts {
+ if opt.Op != Add && opt.Op != Remove && opt.Op != Replace {
+ return nil, fmt.Errorf("Invalid Op: %v", opt.Op)
+ }
if opt.Op == "" {
return nil, no("Op")
}
diff --git a/openstack/cdn/v1/services/requests_test.go b/openstack/cdn/v1/services/requests_test.go
index d06afcb..ca7c269 100644
--- a/openstack/cdn/v1/services/requests_test.go
+++ b/openstack/cdn/v1/services/requests_test.go
@@ -292,7 +292,7 @@
th.AssertDeepEquals(t, expected, actual)
}
-func TestUpdate(t *testing.T) {
+func TestSuccessfulUpdate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
@@ -322,6 +322,36 @@
th.AssertEquals(t, expected, actual)
}
+func TestUnsuccessfulUpdate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ HandleUpdateCDNServiceSuccessfully(t)
+
+ updateOpts := UpdateOpts{
+ UpdateOpt{
+ Op: "Foo",
+ Path: "/origins/0",
+ Value: map[string]interface{}{
+ "origin": "44.33.22.11",
+ "port": 80,
+ "ssl": false,
+ },
+ },
+ UpdateOpt{
+ Op: Add,
+ Path: "/domains/0",
+ Value: map[string]interface{}{
+ "domain": "added.mocksite4.com",
+ },
+ },
+ }
+ _, err := Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", updateOpts).Extract()
+ if err == nil {
+ t.Errorf("Expected error during TestUnsuccessfulUpdate but didn't get one.")
+ }
+}
+
func TestDelete(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
diff --git a/rackspace/cdn/v1/flavors/delegate_test.go b/rackspace/cdn/v1/flavors/delegate_test.go
index 9060e54..d6d299d 100644
--- a/rackspace/cdn/v1/flavors/delegate_test.go
+++ b/rackspace/cdn/v1/flavors/delegate_test.go
@@ -34,7 +34,7 @@
Provider: "Fastly",
Links: []gophercloud.Link{
gophercloud.Link{
- Href: "http: //www.fastly.com",
+ Href: "http://www.fastly.com",
Rel: "provider_url",
},
},
@@ -54,10 +54,7 @@
return true, nil
})
th.AssertNoErr(t, err)
-
- if count != 1 {
- t.Errorf("Expected 1 page, got %d", count)
- }
+ th.CheckEquals(t, 1, count)
}
func TestGet(t *testing.T) {
diff --git a/rackspace/cdn/v1/services/delegate_test.go b/rackspace/cdn/v1/services/delegate_test.go
index baaa439..f833cab 100644
--- a/rackspace/cdn/v1/services/delegate_test.go
+++ b/rackspace/cdn/v1/services/delegate_test.go
@@ -292,7 +292,7 @@
th.AssertDeepEquals(t, expected, actual)
}
-func TestUpdate(t *testing.T) {
+func TestSuccessfulUpdate(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
@@ -322,6 +322,36 @@
th.AssertEquals(t, expected, actual)
}
+func TestUnsuccessfulUpdate(t *testing.T) {
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
+
+ os.HandleUpdateCDNServiceSuccessfully(t)
+
+ updateOpts := os.UpdateOpts{
+ os.UpdateOpt{
+ Op: "Foo",
+ Path: "/origins/0",
+ Value: map[string]interface{}{
+ "origin": "44.33.22.11",
+ "port": 80,
+ "ssl": false,
+ },
+ },
+ os.UpdateOpt{
+ Op: os.Add,
+ Path: "/domains/0",
+ Value: map[string]interface{}{
+ "domain": "added.mocksite4.com",
+ },
+ },
+ }
+ _, err := Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", updateOpts).Extract()
+ if err == nil {
+ t.Errorf("Expected error during TestUnsuccessfulUpdate but didn't get one.")
+ }
+}
+
func TestDelete(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()