blob: 04ee814e99fe4e0544f7ccd1d6f402147c371f5a [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}
25 actual, err := Enable(fake.ServiceClient(), "testContainer", options).ExtractHeaders()
26 th.AssertNoErr(t, err)
27 th.CheckEquals(t, actual["X-Ttl"][0], "259200")
28 th.CheckEquals(t, actual["X-Cdn-Enabled"][0], "True")
29}