Jon Perritt | 457f8ca | 2014-10-15 00:28:23 -0500 | [diff] [blame] | 1 | // +build fixtures |
| 2 | |
| 3 | package accounts |
| 4 | |
| 5 | import ( |
| 6 | "net/http" |
| 7 | "testing" |
| 8 | |
| 9 | th "github.com/rackspace/gophercloud/testhelper" |
| 10 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 11 | ) |
| 12 | |
| 13 | // HandleGetAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that |
| 14 | // responds with a `Get` response. |
| 15 | func HandleGetAccountSuccessfully(t *testing.T) { |
| 16 | th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
| 17 | th.TestMethod(t, r, "POST") |
| 18 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 19 | th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts") |
| 20 | |
| 21 | w.Header().Set("X-Account-Container-Count", "2") |
| 22 | w.Header().Set("X-Account-Bytes-Used", "14") |
| 23 | w.Header().Set("X-Account-Meta-Subject", "books") |
| 24 | |
| 25 | w.WriteHeader(http.StatusNoContent) |
| 26 | }) |
| 27 | } |
| 28 | |
| 29 | // HandleUpdateAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that |
| 30 | // responds with a `Update` response. |
| 31 | func HandleUpdateAccountSuccessfully(t *testing.T) { |
| 32 | th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
| 33 | th.TestMethod(t, r, "HEAD") |
| 34 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 35 | w.Header().Set("X-Account-Meta-Foo", "bar") |
| 36 | w.WriteHeader(http.StatusNoContent) |
| 37 | }) |
| 38 | } |