CDN services tests pass again.
diff --git a/openstack/cdn/v1/services/requests_test.go b/openstack/cdn/v1/services/requests_test.go
index ca7c269..99e2f53 100644
--- a/openstack/cdn/v1/services/requests_test.go
+++ b/openstack/cdn/v1/services/requests_test.go
@@ -129,8 +129,8 @@
},
},
Restrictions: []Restriction{},
- FlavorID: "europe",
- Status: "deployed",
+ FlavorID: "europe",
+ Status: "deployed",
Links: []gophercloud.Link{
gophercloud.Link{
Href: "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1",
@@ -160,204 +160,169 @@
}
func TestCreate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
- HandleCreateCDNServiceSuccessfully(t)
+ HandleCreateCDNServiceSuccessfully(t)
- createOpts := CreateOpts{
- Name: "mywebsite.com",
- Domains: []Domain{
- Domain{
- Domain: "www.mywebsite.com",
- },
- Domain{
- Domain: "blog.mywebsite.com",
- },
- },
- Origins: []Origin{
- Origin{
- Origin: "mywebsite.com",
- Port: 80,
- SSL: false,
- },
- },
- Restrictions: []Restriction{
- Restriction{
- Name: "website only",
- Rules: []RestrictionRule{
- RestrictionRule{
- Name: "mywebsite.com",
- Referrer: "www.mywebsite.com",
- },
- },
- },
- },
- Caching: []CacheRule{
- CacheRule{
- Name: "default",
- TTL: 3600,
- },
- },
- FlavorID: "cdn",
- }
+ createOpts := CreateOpts{
+ Name: "mywebsite.com",
+ Domains: []Domain{
+ Domain{
+ Domain: "www.mywebsite.com",
+ },
+ Domain{
+ Domain: "blog.mywebsite.com",
+ },
+ },
+ Origins: []Origin{
+ Origin{
+ Origin: "mywebsite.com",
+ Port: 80,
+ SSL: false,
+ },
+ },
+ Restrictions: []Restriction{
+ Restriction{
+ Name: "website only",
+ Rules: []RestrictionRule{
+ RestrictionRule{
+ Name: "mywebsite.com",
+ Referrer: "www.mywebsite.com",
+ },
+ },
+ },
+ },
+ Caching: []CacheRule{
+ CacheRule{
+ Name: "default",
+ TTL: 3600,
+ },
+ },
+ FlavorID: "cdn",
+ }
- expected := "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
- actual, err := Create(fake.ServiceClient(), createOpts).Extract()
- th.AssertNoErr(t, err)
- th.AssertEquals(t, expected, actual)
+ expected := "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
+ actual, err := Create(fake.ServiceClient(), createOpts).Extract()
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, expected, actual)
}
func TestGet(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
- HandleGetCDNServiceSuccessfully(t)
+ HandleGetCDNServiceSuccessfully(t)
- expected := &Service{
- ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
- Name: "mywebsite.com",
- Domains: []Domain{
- Domain{
- Domain: "www.mywebsite.com",
- Protocol: "http",
- },
- },
- Origins: []Origin{
- Origin{
- Origin: "mywebsite.com",
- Port: 80,
- SSL: false,
- },
- },
- Caching: []CacheRule{
- CacheRule{
- Name: "default",
- TTL: 3600,
- },
- CacheRule{
- Name: "home",
- TTL: 17200,
- Rules: []TTLRule{
- TTLRule{
- Name: "index",
- RequestURL: "/index.htm",
- },
- },
- },
- CacheRule{
- Name: "images",
- TTL: 12800,
- Rules: []TTLRule{
- TTLRule{
- Name: "images",
- RequestURL: "*.png",
- },
- },
- },
- },
- Restrictions: []Restriction{
- Restriction{
- Name: "website only",
- Rules: []RestrictionRule{
- RestrictionRule{
- Name: "mywebsite.com",
- Referrer: "www.mywebsite.com",
- },
- },
- },
- },
- FlavorID: "cdn",
- Status: "deployed",
- Errors: []Error{},
- Links: []gophercloud.Link{
- gophercloud.Link{
- Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
- Rel: "self",
- },
- gophercloud.Link{
- Href: "blog.mywebsite.com.cdn1.raxcdn.com",
- Rel: "access_url",
- },
- gophercloud.Link{
- Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/flavors/cdn",
- Rel: "flavor",
- },
- },
- }
+ expected := &Service{
+ ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
+ Name: "mywebsite.com",
+ Domains: []Domain{
+ Domain{
+ Domain: "www.mywebsite.com",
+ Protocol: "http",
+ },
+ },
+ Origins: []Origin{
+ Origin{
+ Origin: "mywebsite.com",
+ Port: 80,
+ SSL: false,
+ },
+ },
+ Caching: []CacheRule{
+ CacheRule{
+ Name: "default",
+ TTL: 3600,
+ },
+ CacheRule{
+ Name: "home",
+ TTL: 17200,
+ Rules: []TTLRule{
+ TTLRule{
+ Name: "index",
+ RequestURL: "/index.htm",
+ },
+ },
+ },
+ CacheRule{
+ Name: "images",
+ TTL: 12800,
+ Rules: []TTLRule{
+ TTLRule{
+ Name: "images",
+ RequestURL: "*.png",
+ },
+ },
+ },
+ },
+ Restrictions: []Restriction{
+ Restriction{
+ Name: "website only",
+ Rules: []RestrictionRule{
+ RestrictionRule{
+ Name: "mywebsite.com",
+ Referrer: "www.mywebsite.com",
+ },
+ },
+ },
+ },
+ FlavorID: "cdn",
+ Status: "deployed",
+ Errors: []Error{},
+ Links: []gophercloud.Link{
+ gophercloud.Link{
+ Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0",
+ Rel: "self",
+ },
+ gophercloud.Link{
+ Href: "blog.mywebsite.com.cdn1.raxcdn.com",
+ Rel: "access_url",
+ },
+ gophercloud.Link{
+ Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/flavors/cdn",
+ Rel: "flavor",
+ },
+ },
+ }
-
- actual, err := Get(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").Extract()
- th.AssertNoErr(t, err)
- th.AssertDeepEquals(t, expected, actual)
+ actual, err := Get(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").Extract()
+ th.AssertNoErr(t, err)
+ th.AssertDeepEquals(t, expected, actual)
}
func TestSuccessfulUpdate(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
-
- HandleUpdateCDNServiceSuccessfully(t)
-
- expected := "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
- updateOpts := UpdateOpts{
- UpdateOpt{
- Op: Replace,
- 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",
- },
- },
- }
- actual, err := Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", updateOpts).Extract()
- th.AssertNoErr(t, err)
- 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,
+ 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,
},
- UpdateOpt{
- Op: Add,
- Path: "/domains/0",
- Value: map[string]interface{}{
- "domain": "added.mocksite4.com",
- },
+ Addition{
+ Value: Domain{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.")
- }
+
+ actual, err := Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", ops).Extract()
+ th.AssertNoErr(t, err)
+ th.AssertEquals(t, expected, actual)
}
func TestDelete(t *testing.T) {
- th.SetupHTTP()
- defer th.TeardownHTTP()
+ th.SetupHTTP()
+ defer th.TeardownHTTP()
- HandleDeleteCDNServiceSuccessfully(t)
+ HandleDeleteCDNServiceSuccessfully(t)
- err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").ExtractErr()
- th.AssertNoErr(t, err)
+ err := Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").ExtractErr()
+ th.AssertNoErr(t, err)
}