blob: 66589bf4bf1d5f2821d764d32f5e707f396afa88 [file] [log] [blame]
Jon Perritt457f8ca2014-10-15 00:28:23 -05001// +build fixtures
2
3package accounts
4
5import (
6 "net/http"
7 "testing"
8
Jon Perritt27249f42016-02-18 10:35:59 -06009 th "github.com/gophercloud/gophercloud/testhelper"
10 fake "github.com/gophercloud/gophercloud/testhelper/client"
Jon Perritt457f8ca2014-10-15 00:28:23 -050011)
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) {
Jon Perrittae06ab72014-11-06 18:18:55 -060017 th.TestMethod(t, r, "HEAD")
Jon Perritt457f8ca2014-10-15 00:28:23 -050018 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
Jon Perritt457f8ca2014-10-15 00:28:23 -050019
20 w.Header().Set("X-Account-Container-Count", "2")
21 w.Header().Set("X-Account-Bytes-Used", "14")
22 w.Header().Set("X-Account-Meta-Subject", "books")
23
24 w.WriteHeader(http.StatusNoContent)
25 })
26}
27
28// HandleUpdateAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that
29// responds with a `Update` response.
30func HandleUpdateAccountSuccessfully(t *testing.T) {
31 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Jon Perrittae06ab72014-11-06 18:18:55 -060032 th.TestMethod(t, r, "POST")
Jon Perritt457f8ca2014-10-15 00:28:23 -050033 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
Jon Perrittae06ab72014-11-06 18:18:55 -060034 th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts")
35
Jon Perritt457f8ca2014-10-15 00:28:23 -050036 w.WriteHeader(http.StatusNoContent)
37 })
38}