blob: a2651995d6d41bc789b05835b533f921e7b3e0a2 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Jon Perritt457f8ca2014-10-15 00:28:23 -05002
3import (
4 "net/http"
5 "testing"
6
Jon Perritt27249f42016-02-18 10:35:59 -06007 th "github.com/gophercloud/gophercloud/testhelper"
8 fake "github.com/gophercloud/gophercloud/testhelper/client"
Jon Perritt457f8ca2014-10-15 00:28:23 -05009)
10
11// HandleGetAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that
12// responds with a `Get` response.
13func HandleGetAccountSuccessfully(t *testing.T) {
14 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Jon Perrittae06ab72014-11-06 18:18:55 -060015 th.TestMethod(t, r, "HEAD")
Jon Perritt457f8ca2014-10-15 00:28:23 -050016 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
Jon Perritt457f8ca2014-10-15 00:28:23 -050017
18 w.Header().Set("X-Account-Container-Count", "2")
19 w.Header().Set("X-Account-Bytes-Used", "14")
20 w.Header().Set("X-Account-Meta-Subject", "books")
Jon Perritt3c166472016-02-25 03:07:41 -060021 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
Jon Perritt457f8ca2014-10-15 00:28:23 -050022
23 w.WriteHeader(http.StatusNoContent)
24 })
25}
26
27// HandleUpdateAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that
28// responds with a `Update` response.
29func HandleUpdateAccountSuccessfully(t *testing.T) {
30 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Jon Perrittae06ab72014-11-06 18:18:55 -060031 th.TestMethod(t, r, "POST")
Jon Perritt457f8ca2014-10-15 00:28:23 -050032 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
Jon Perrittae06ab72014-11-06 18:18:55 -060033 th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts")
34
Jon Perritt3c166472016-02-25 03:07:41 -060035 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
Jon Perritt457f8ca2014-10-15 00:28:23 -050036 w.WriteHeader(http.StatusNoContent)
37 })
38}