blob: 3dad0c5a9be20e9f4a49fcd4686b1129c9760ecc [file] [log] [blame]
Jon Perritt457f8ca2014-10-15 00:28:23 -05001// +build fixtures
2
3package accounts
4
5import (
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.
15func 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.
31func 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}