blob: e2c33fe2d5c99ae5762f6c305f11d18a3084fc0c [file] [log] [blame]
Keith Byrnebda48592016-03-23 11:37:08 +00001// +build fixtures
2
Jamie Hannaford583e23d2014-11-13 13:22:29 +01003package startstop
4
5import (
6 "net/http"
7 "testing"
8
9 th "github.com/rackspace/gophercloud/testhelper"
10 "github.com/rackspace/gophercloud/testhelper/client"
11)
12
13func mockStartServerResponse(t *testing.T, id string) {
14 th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) {
15 th.TestMethod(t, r, "POST")
16 th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
17 th.TestJSONRequest(t, r, `{"os-start": null}`)
18 w.WriteHeader(http.StatusAccepted)
19 })
20}
21
22func mockStopServerResponse(t *testing.T, id string) {
23 th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) {
24 th.TestMethod(t, r, "POST")
25 th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
26 th.TestJSONRequest(t, r, `{"os-stop": null}`)
27 w.WriteHeader(http.StatusAccepted)
28 })
29}