github.com/gophercloud/gophercloud@v1.11.0/openstack/objectstorage/v1/accounts/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "net/http" 5 "testing" 6 7 th "github.com/gophercloud/gophercloud/testhelper" 8 fake "github.com/gophercloud/gophercloud/testhelper/client" 9 ) 10 11 // HandleGetAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that 12 // responds with a `Get` response. 13 func HandleGetAccountSuccessfully(t *testing.T) { 14 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 15 th.TestMethod(t, r, "HEAD") 16 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 17 18 w.Header().Set("X-Account-Container-Count", "2") 19 w.Header().Set("X-Account-Object-Count", "5") 20 w.Header().Set("X-Account-Meta-Quota-Bytes", "42") 21 w.Header().Set("X-Account-Bytes-Used", "14") 22 w.Header().Set("X-Account-Meta-Subject", "books") 23 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 UTC") 24 w.Header().Set("X-Account-Meta-Temp-URL-Key", "testsecret") 25 26 w.WriteHeader(http.StatusNoContent) 27 }) 28 } 29 30 // HandleGetAccountNoQuotaSuccessfully creates an HTTP handler at `/` on the 31 // test handler mux that responds with a `Get` response. 32 func HandleGetAccountNoQuotaSuccessfully(t *testing.T) { 33 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 34 th.TestMethod(t, r, "HEAD") 35 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 36 37 w.Header().Set("X-Account-Container-Count", "2") 38 w.Header().Set("X-Account-Object-Count", "5") 39 w.Header().Set("X-Account-Bytes-Used", "14") 40 w.Header().Set("X-Account-Meta-Subject", "books") 41 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 UTC") 42 43 w.WriteHeader(http.StatusNoContent) 44 }) 45 } 46 47 // HandleUpdateAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that 48 // responds with a `Update` response. 49 func HandleUpdateAccountSuccessfully(t *testing.T) { 50 th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 51 th.TestMethod(t, r, "POST") 52 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) 53 th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts") 54 th.TestHeader(t, r, "X-Remove-Account-Meta-Gophercloud-Test-Remove", "remove") 55 th.TestHeader(t, r, "Content-Type", "") 56 th.TestHeader(t, r, "X-Detect-Content-Type", "false") 57 th.TestHeaderUnset(t, r, "X-Account-Meta-Temp-URL-Key") 58 59 w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 UTC") 60 w.WriteHeader(http.StatusNoContent) 61 }) 62 }