Exercise all cases in the Update fixture.
diff --git a/openstack/cdn/v1/services/fixtures.go b/openstack/cdn/v1/services/fixtures.go
index dd35d58..9fecb19 100644
--- a/openstack/cdn/v1/services/fixtures.go
+++ b/openstack/cdn/v1/services/fixtures.go
@@ -310,20 +310,41 @@
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
th.TestJSONRequest(t, r, `
[
- {
- "op": "replace",
- "path": "/origins/0",
- "value": {
- "origin": "44.33.22.11",
- "port": 80,
- "ssl": false
- }
- },
- {
- "op": "add",
- "path": "/domains/-",
- "value": {"domain": "added.mocksite4.com"}
- }
+ {
+ "op": "add",
+ "path": "/domains/-",
+ "value": {"domain": "appended.mocksite4.com"}
+ },
+ {
+ "op": "add",
+ "path": "/domains/4",
+ "value": {"domain": "inserted.mocksite4.com"}
+ },
+ {
+ "op": "add",
+ "path": "/domains",
+ "value": [
+ {"domain": "bulkadded1.mocksite4.com"},
+ {"domain": "bulkadded2.mocksite4.com"}
+ ]
+ },
+ {
+ "op": "replace",
+ "path": "/origins/2",
+ "value": {"origin": "44.33.22.11", "port": 80, "ssl": false}
+ },
+ {
+ "op": "replace",
+ "path": "/origins",
+ "value": [
+ {"origin": "44.33.22.11", "port": 80, "ssl": false},
+ {"origin": "55.44.33.22", "port": 443, "ssl": true}
+ ]
+ },
+ {
+ "op": "remove",
+ "path": "/caching/8"
+ }
]
`)
w.Header().Add("Location", "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0")
diff --git a/openstack/cdn/v1/services/requests_test.go b/openstack/cdn/v1/services/requests_test.go
index e029d63..ca35453 100644
--- a/openstack/cdn/v1/services/requests_test.go
+++ b/openstack/cdn/v1/services/requests_test.go
@@ -299,16 +299,37 @@
expected := "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
ops := []Patch{
- Replacement{
- Value: Origin{
- Origin: "44.33.22.11",
- Port: 80,
- SSL: false,
- },
- Index: 0,
+ // Append a single Domain
+ Append{Value: Domain{Domain: "appended.mocksite4.com"}},
+ // Insert a single Domain
+ Insertion{
+ Index: 4,
+ Value: Domain{Domain: "inserted.mocksite4.com"},
},
+ // Bulk addition
Append{
- Value: Domain{Domain: "added.mocksite4.com"},
+ Value: DomainList{
+ Domain{Domain: "bulkadded1.mocksite4.com"},
+ Domain{Domain: "bulkadded2.mocksite4.com"},
+ },
+ },
+ // Replace a single Origin
+ Replacement{
+ Index: 2,
+ Value: Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
+ },
+ // Bulk replace Origins
+ Replacement{
+ Index: 0, // Ignored
+ Value: OriginList{
+ Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
+ Origin{Origin: "55.44.33.22", Port: 443, SSL: true},
+ },
+ },
+ // Remove a single CacheRule
+ Removal{
+ Index: 8,
+ Path: PathCaching,
},
}
diff --git a/openstack/cdn/v1/services/results.go b/openstack/cdn/v1/services/results.go
index 40581a4..33406c4 100644
--- a/openstack/cdn/v1/services/results.go
+++ b/openstack/cdn/v1/services/results.go
@@ -100,7 +100,7 @@
}
// OriginList provides a useful way to perform bulk operations in a single Patch.
-type OriginList []Domain
+type OriginList []Origin
func (list OriginList) toPatchValue() interface{} {
r := make([]interface{}, len(list))
@@ -158,7 +158,7 @@
}
// CacheRuleList provides a useful way to perform bulk operations in a single Patch.
-type CacheRuleList []Domain
+type CacheRuleList []CacheRule
func (list CacheRuleList) toPatchValue() interface{} {
r := make([]interface{}, len(list))
diff --git a/rackspace/cdn/v1/services/delegate_test.go b/rackspace/cdn/v1/services/delegate_test.go
index e2ebb00..ad2aa81 100644
--- a/rackspace/cdn/v1/services/delegate_test.go
+++ b/rackspace/cdn/v1/services/delegate_test.go
@@ -300,16 +300,37 @@
expected := "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
ops := []os.Patch{
- os.Replacement{
- Value: os.Origin{
- Origin: "44.33.22.11",
- Port: 80,
- SSL: false,
- },
- Index: 0,
+ // Append a single Domain
+ os.Append{Value: os.Domain{Domain: "appended.mocksite4.com"}},
+ // Insert a single Domain
+ os.Insertion{
+ Index: 4,
+ Value: os.Domain{Domain: "inserted.mocksite4.com"},
},
+ // Bulk addition
os.Append{
- Value: os.Domain{Domain: "added.mocksite4.com"},
+ Value: os.DomainList{
+ os.Domain{Domain: "bulkadded1.mocksite4.com"},
+ os.Domain{Domain: "bulkadded2.mocksite4.com"},
+ },
+ },
+ // Replace a single Origin
+ os.Replacement{
+ Index: 2,
+ Value: os.Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
+ },
+ // Bulk replace Origins
+ os.Replacement{
+ Index: 0, // Ignored
+ Value: os.OriginList{
+ os.Origin{Origin: "44.33.22.11", Port: 80, SSL: false},
+ os.Origin{Origin: "55.44.33.22", Port: 443, SSL: true},
+ },
+ },
+ // Remove a single CacheRule
+ os.Removal{
+ Index: 8,
+ Path: os.PathCaching,
},
}