fixtures.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package testing
  2. import (
  3. "net/http"
  4. "testing"
  5. th "devel.mephi.ru/iacherepanov/openstack-gophercloud/testhelper"
  6. fake "devel.mephi.ru/iacherepanov/openstack-gophercloud/testhelper/client"
  7. )
  8. // HandleGetAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that
  9. // responds with a `Get` response.
  10. func HandleGetAccountSuccessfully(t *testing.T) {
  11. th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  12. th.TestMethod(t, r, "HEAD")
  13. th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
  14. w.Header().Set("X-Account-Container-Count", "2")
  15. w.Header().Set("X-Account-Object-Count", "5")
  16. w.Header().Set("X-Account-Meta-Quota-Bytes", "42")
  17. w.Header().Set("X-Account-Bytes-Used", "14")
  18. w.Header().Set("X-Account-Meta-Subject", "books")
  19. w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
  20. w.WriteHeader(http.StatusNoContent)
  21. })
  22. }
  23. // HandleGetAccountNoQuotaSuccessfully creates an HTTP handler at `/` on the
  24. // test handler mux that responds with a `Get` response.
  25. func HandleGetAccountNoQuotaSuccessfully(t *testing.T) {
  26. th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  27. th.TestMethod(t, r, "HEAD")
  28. th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
  29. w.Header().Set("X-Account-Container-Count", "2")
  30. w.Header().Set("X-Account-Object-Count", "5")
  31. w.Header().Set("X-Account-Bytes-Used", "14")
  32. w.Header().Set("X-Account-Meta-Subject", "books")
  33. w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
  34. w.WriteHeader(http.StatusNoContent)
  35. })
  36. }
  37. // HandleUpdateAccountSuccessfully creates an HTTP handler at `/` on the test handler mux that
  38. // responds with a `Update` response.
  39. func HandleUpdateAccountSuccessfully(t *testing.T) {
  40. th.Mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
  41. th.TestMethod(t, r, "POST")
  42. th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
  43. th.TestHeader(t, r, "X-Account-Meta-Gophercloud-Test", "accounts")
  44. w.Header().Set("Date", "Fri, 17 Jan 2014 16:09:56 GMT")
  45. w.WriteHeader(http.StatusNoContent)
  46. })
  47. }