blob: 28b963dacef1b02364a27934b89dcf0a50546906 [file] [log] [blame]
Jon Perrittb5c78122014-10-15 20:44:39 -05001package cdncontainers
Jon Perritt0ba5a562014-10-15 23:23:12 -05002
3import (
4 "net/http"
5 "testing"
6
7 th "github.com/rackspace/gophercloud/testhelper"
8 fake "github.com/rackspace/gophercloud/testhelper/client"
9)
10
11func TestEnableCDNContainer(t *testing.T) {
12 th.SetupHTTP()
13 defer th.TeardownHTTP()
14 th.Mux.HandleFunc("/testContainer", func(w http.ResponseWriter, r *http.Request) {
15 th.TestMethod(t, r, "PUT")
16 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
17 th.TestHeader(t, r, "Accept", "application/json")
18
19 w.Header().Add("X-Ttl", "259200")
20 w.Header().Add("X-Cdn-Enabled", "True")
21 w.WriteHeader(http.StatusNoContent)
22 })
23
24 options := &EnableOpts{CDNEnabled: true, TTL: 259200}
Jon Perritt0ce24ad2014-10-20 21:59:45 -050025 actual := Enable(fake.ServiceClient(), "testContainer", options)
26 th.AssertNoErr(t, actual.Err)
27 th.CheckEquals(t, actual.Header["X-Ttl"][0], "259200")
28 th.CheckEquals(t, actual.Header["X-Cdn-Enabled"][0], "True")
Jon Perritt0ba5a562014-10-15 23:23:12 -050029}