jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 1 | package testing |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 6 | "github.com/gophercloud/gophercloud" |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 7 | "github.com/gophercloud/gophercloud/openstack/cdn/v1/services" |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 8 | "github.com/gophercloud/gophercloud/pagination" |
| 9 | th "github.com/gophercloud/gophercloud/testhelper" |
| 10 | fake "github.com/gophercloud/gophercloud/testhelper/client" |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 11 | ) |
| 12 | |
| 13 | func TestList(t *testing.T) { |
| 14 | th.SetupHTTP() |
| 15 | defer th.TeardownHTTP() |
| 16 | |
| 17 | HandleListCDNServiceSuccessfully(t) |
| 18 | |
| 19 | count := 0 |
| 20 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 21 | err := services.List(fake.ServiceClient(), &services.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 22 | count++ |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 23 | actual, err := services.ExtractServices(page) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 24 | if err != nil { |
| 25 | t.Errorf("Failed to extract services: %v", err) |
| 26 | return false, err |
| 27 | } |
| 28 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 29 | expected := []services.Service{ |
| 30 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 31 | ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", |
| 32 | Name: "mywebsite.com", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 33 | Domains: []services.Domain{ |
| 34 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 35 | Domain: "www.mywebsite.com", |
| 36 | }, |
| 37 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 38 | Origins: []services.Origin{ |
| 39 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 40 | Origin: "mywebsite.com", |
| 41 | Port: 80, |
| 42 | SSL: false, |
| 43 | }, |
| 44 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 45 | Caching: []services.CacheRule{ |
| 46 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 47 | Name: "default", |
| 48 | TTL: 3600, |
| 49 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 50 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 51 | Name: "home", |
| 52 | TTL: 17200, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 53 | Rules: []services.TTLRule{ |
| 54 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 55 | Name: "index", |
| 56 | RequestURL: "/index.htm", |
| 57 | }, |
| 58 | }, |
| 59 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 60 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 61 | Name: "images", |
| 62 | TTL: 12800, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 63 | Rules: []services.TTLRule{ |
| 64 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 65 | Name: "images", |
| 66 | RequestURL: "*.png", |
| 67 | }, |
| 68 | }, |
| 69 | }, |
| 70 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 71 | Restrictions: []services.Restriction{ |
| 72 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 73 | Name: "website only", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 74 | Rules: []services.RestrictionRule{ |
| 75 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 76 | Name: "mywebsite.com", |
| 77 | Referrer: "www.mywebsite.com", |
| 78 | }, |
| 79 | }, |
| 80 | }, |
| 81 | }, |
| 82 | FlavorID: "asia", |
| 83 | Status: "deployed", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 84 | Errors: []services.Error{}, |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 85 | Links: []gophercloud.Link{ |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 86 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 87 | Href: "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", |
| 88 | Rel: "self", |
| 89 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 90 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 91 | Href: "mywebsite.com.cdn123.poppycdn.net", |
| 92 | Rel: "access_url", |
| 93 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 94 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 95 | Href: "https://www.poppycdn.io/v1.0/flavors/asia", |
| 96 | Rel: "flavor", |
| 97 | }, |
| 98 | }, |
| 99 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 100 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 101 | ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1", |
| 102 | Name: "myothersite.com", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 103 | Domains: []services.Domain{ |
| 104 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 105 | Domain: "www.myothersite.com", |
| 106 | }, |
| 107 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 108 | Origins: []services.Origin{ |
| 109 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 110 | Origin: "44.33.22.11", |
| 111 | Port: 80, |
| 112 | SSL: false, |
| 113 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 114 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 115 | Origin: "77.66.55.44", |
| 116 | Port: 80, |
| 117 | SSL: false, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 118 | Rules: []services.OriginRule{ |
| 119 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 120 | Name: "videos", |
| 121 | RequestURL: "^/videos/*.m3u", |
| 122 | }, |
| 123 | }, |
| 124 | }, |
| 125 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 126 | Caching: []services.CacheRule{ |
| 127 | { |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 128 | Name: "default", |
| 129 | TTL: 3600, |
| 130 | }, |
| 131 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 132 | Restrictions: []services.Restriction{}, |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 133 | FlavorID: "europe", |
| 134 | Status: "deployed", |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 135 | Links: []gophercloud.Link{ |
| 136 | gophercloud.Link{ |
| 137 | Href: "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f1", |
| 138 | Rel: "self", |
| 139 | }, |
| 140 | gophercloud.Link{ |
| 141 | Href: "myothersite.com.poppycdn.net", |
| 142 | Rel: "access_url", |
| 143 | }, |
| 144 | gophercloud.Link{ |
| 145 | Href: "https://www.poppycdn.io/v1.0/flavors/europe", |
| 146 | Rel: "flavor", |
| 147 | }, |
| 148 | }, |
| 149 | }, |
| 150 | } |
| 151 | |
| 152 | th.CheckDeepEquals(t, expected, actual) |
| 153 | |
| 154 | return true, nil |
| 155 | }) |
| 156 | th.AssertNoErr(t, err) |
| 157 | |
| 158 | if count != 1 { |
| 159 | t.Errorf("Expected 1 page, got %d", count) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func TestCreate(t *testing.T) { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 164 | th.SetupHTTP() |
| 165 | defer th.TeardownHTTP() |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 166 | |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 167 | HandleCreateCDNServiceSuccessfully(t) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 168 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 169 | createOpts := services.CreateOpts{ |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 170 | Name: "mywebsite.com", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 171 | Domains: []services.Domain{ |
| 172 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 173 | Domain: "www.mywebsite.com", |
| 174 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 175 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 176 | Domain: "blog.mywebsite.com", |
| 177 | }, |
| 178 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 179 | Origins: []services.Origin{ |
| 180 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 181 | Origin: "mywebsite.com", |
| 182 | Port: 80, |
| 183 | SSL: false, |
| 184 | }, |
| 185 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 186 | Restrictions: []services.Restriction{ |
| 187 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 188 | Name: "website only", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 189 | Rules: []services.RestrictionRule{ |
| 190 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 191 | Name: "mywebsite.com", |
| 192 | Referrer: "www.mywebsite.com", |
| 193 | }, |
| 194 | }, |
| 195 | }, |
| 196 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 197 | Caching: []services.CacheRule{ |
| 198 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 199 | Name: "default", |
| 200 | TTL: 3600, |
| 201 | }, |
| 202 | }, |
| 203 | FlavorID: "cdn", |
| 204 | } |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 205 | |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 206 | expected := "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 207 | actual, err := services.Create(fake.ServiceClient(), createOpts).Extract() |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 208 | th.AssertNoErr(t, err) |
| 209 | th.AssertEquals(t, expected, actual) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | func TestGet(t *testing.T) { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 213 | th.SetupHTTP() |
| 214 | defer th.TeardownHTTP() |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 215 | |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 216 | HandleGetCDNServiceSuccessfully(t) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 217 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 218 | expected := &services.Service{ |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 219 | ID: "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", |
| 220 | Name: "mywebsite.com", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 221 | Domains: []services.Domain{ |
| 222 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 223 | Domain: "www.mywebsite.com", |
| 224 | Protocol: "http", |
| 225 | }, |
| 226 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 227 | Origins: []services.Origin{ |
| 228 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 229 | Origin: "mywebsite.com", |
| 230 | Port: 80, |
| 231 | SSL: false, |
| 232 | }, |
| 233 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 234 | Caching: []services.CacheRule{ |
| 235 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 236 | Name: "default", |
| 237 | TTL: 3600, |
| 238 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 239 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 240 | Name: "home", |
| 241 | TTL: 17200, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 242 | Rules: []services.TTLRule{ |
| 243 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 244 | Name: "index", |
| 245 | RequestURL: "/index.htm", |
| 246 | }, |
| 247 | }, |
| 248 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 249 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 250 | Name: "images", |
| 251 | TTL: 12800, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 252 | Rules: []services.TTLRule{ |
| 253 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 254 | Name: "images", |
| 255 | RequestURL: "*.png", |
| 256 | }, |
| 257 | }, |
| 258 | }, |
| 259 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 260 | Restrictions: []services.Restriction{ |
| 261 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 262 | Name: "website only", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 263 | Rules: []services.RestrictionRule{ |
| 264 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 265 | Name: "mywebsite.com", |
| 266 | Referrer: "www.mywebsite.com", |
| 267 | }, |
| 268 | }, |
| 269 | }, |
| 270 | }, |
| 271 | FlavorID: "cdn", |
| 272 | Status: "deployed", |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 273 | Errors: []services.Error{}, |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 274 | Links: []gophercloud.Link{ |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 275 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 276 | Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", |
| 277 | Rel: "self", |
| 278 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 279 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 280 | Href: "blog.mywebsite.com.cdn1.raxcdn.com", |
| 281 | Rel: "access_url", |
| 282 | }, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 283 | { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 284 | Href: "https://global.cdn.api.rackspacecloud.com/v1.0/110011/flavors/cdn", |
| 285 | Rel: "flavor", |
| 286 | }, |
| 287 | }, |
| 288 | } |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 289 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 290 | actual, err := services.Get(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").Extract() |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 291 | th.AssertNoErr(t, err) |
| 292 | th.AssertDeepEquals(t, expected, actual) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Jon Perritt | 1e5e293 | 2015-01-27 12:13:19 -0700 | [diff] [blame] | 295 | func TestSuccessfulUpdate(t *testing.T) { |
Jon Perritt | 1e5e293 | 2015-01-27 12:13:19 -0700 | [diff] [blame] | 296 | th.SetupHTTP() |
| 297 | defer th.TeardownHTTP() |
| 298 | |
| 299 | HandleUpdateCDNServiceSuccessfully(t) |
| 300 | |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 301 | expected := "https://www.poppycdn.io/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 302 | ops := services.UpdateOpts{ |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 303 | // Append a single Domain |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 304 | services.Append{Value: services.Domain{Domain: "appended.mocksite4.com"}}, |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 305 | // Insert a single Domain |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 306 | services.Insertion{ |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 307 | Index: 4, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 308 | Value: services.Domain{Domain: "inserted.mocksite4.com"}, |
Jon Perritt | 1e5e293 | 2015-01-27 12:13:19 -0700 | [diff] [blame] | 309 | }, |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 310 | // Bulk addition |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 311 | services.Append{ |
| 312 | Value: services.DomainList{ |
| 313 | {Domain: "bulkadded1.mocksite4.com"}, |
| 314 | {Domain: "bulkadded2.mocksite4.com"}, |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 315 | }, |
| 316 | }, |
| 317 | // Replace a single Origin |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 318 | services.Replacement{ |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 319 | Index: 2, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 320 | Value: services.Origin{Origin: "44.33.22.11", Port: 80, SSL: false}, |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 321 | }, |
| 322 | // Bulk replace Origins |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 323 | services.Replacement{ |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 324 | Index: 0, // Ignored |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 325 | Value: services.OriginList{ |
| 326 | {Origin: "44.33.22.11", Port: 80, SSL: false}, |
| 327 | {Origin: "55.44.33.22", Port: 443, SSL: true}, |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 328 | }, |
| 329 | }, |
| 330 | // Remove a single CacheRule |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 331 | services.Removal{ |
Ash Wilson | 163e459 | 2015-01-29 12:03:28 -0500 | [diff] [blame] | 332 | Index: 8, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 333 | Path: services.PathCaching, |
Jon Perritt | 1e5e293 | 2015-01-27 12:13:19 -0700 | [diff] [blame] | 334 | }, |
Ash Wilson | d842ae6 | 2015-01-29 13:11:50 -0500 | [diff] [blame] | 335 | // Bulk removal |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 336 | services.Removal{ |
Ash Wilson | d842ae6 | 2015-01-29 13:11:50 -0500 | [diff] [blame] | 337 | All: true, |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 338 | Path: services.PathCaching, |
Ash Wilson | d842ae6 | 2015-01-29 13:11:50 -0500 | [diff] [blame] | 339 | }, |
| 340 | // Service name replacement |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 341 | services.NameReplacement{ |
Ash Wilson | d842ae6 | 2015-01-29 13:11:50 -0500 | [diff] [blame] | 342 | NewName: "differentServiceName", |
| 343 | }, |
Jon Perritt | 1e5e293 | 2015-01-27 12:13:19 -0700 | [diff] [blame] | 344 | } |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 345 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 346 | actual, err := services.Update(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0", ops).Extract() |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 347 | th.AssertNoErr(t, err) |
| 348 | th.AssertEquals(t, expected, actual) |
Jon Perritt | 1e5e293 | 2015-01-27 12:13:19 -0700 | [diff] [blame] | 349 | } |
| 350 | |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 351 | func TestDelete(t *testing.T) { |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 352 | th.SetupHTTP() |
| 353 | defer th.TeardownHTTP() |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 354 | |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 355 | HandleDeleteCDNServiceSuccessfully(t) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 356 | |
jrperritt | 3d96616 | 2016-06-06 14:08:54 -0500 | [diff] [blame] | 357 | err := services.Delete(fake.ServiceClient(), "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0").ExtractErr() |
Ash Wilson | 4cd7aff | 2015-01-29 10:18:09 -0500 | [diff] [blame] | 358 | th.AssertNoErr(t, err) |
Jon Perritt | 9da13a1 | 2015-01-20 19:25:15 -0700 | [diff] [blame] | 359 | } |