Jon Perritt | b5c7812 | 2014-10-15 20:44:39 -0500 | [diff] [blame] | 1 | package cdncontainers |
Jon Perritt | 0ba5a56 | 2014-10-15 23:23:12 -0500 | [diff] [blame^] | 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | "testing" |
| 6 | |
| 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 9 | ) |
| 10 | |
| 11 | func 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 | } |