github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/resetstate/testing/fixtures.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 th "github.com/huaweicloud/golangsdk/testhelper" 9 "github.com/huaweicloud/golangsdk/testhelper/client" 10 ) 11 12 func mockResetStateResponse(t *testing.T, id string, state string) { 13 th.Mux.HandleFunc("/servers/"+id+"/action", func(w http.ResponseWriter, r *http.Request) { 14 th.TestMethod(t, r, "POST") 15 th.TestHeader(t, r, "X-Auth-Token", client.TokenID) 16 th.TestJSONRequest(t, r, fmt.Sprintf(`{"os-resetState": {"state": "%s"}}`, state)) 17 w.WriteHeader(http.StatusAccepted) 18 }) 19 }