blob: 16327e839c8f1c9b2e5555c29e7708d9a35279bf [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")
Jon Perritt3c166472016-02-25 03:07:41 -060023 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
Jon Perritt457f8ca2014-10-15 00:28:23 -050024
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) {
Jon Perrittae06ab72014-11-06 18:18:55 -060033 th.TestMethod(t, r, "POST")
Jon Perritt457f8ca2014-10-15 00:28:23 -050034 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
Jon Perrittae06ab72014-11-06 18:18:55 -060035 th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts")
36
Jon Perritt3c166472016-02-25 03:07:41 -060037 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
Jon Perritt457f8ca2014-10-15 00:28:23 -050038 w.WriteHeader(http.StatusNoContent)
39 })
40}