blob: ca873812d3bde4b6c9c2c89e7d51253ada3f2a6b [file] [log] [blame]
Jon Perritt4a5c8492015-02-03 13:13:59 -07001package stacks
2
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
8 "github.com/rackspace/gophercloud"
9 th "github.com/rackspace/gophercloud/testhelper"
10 fake "github.com/rackspace/gophercloud/testhelper/client"
11)
12
13// CreateExpected represents the expected object from a Create request.
14var CreateExpected = &CreatedStack{
15 ID: "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
16 Links: []gophercloud.Link{
17 gophercloud.Link{
18 Href: "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
19 Rel: "self",
20 },
21 },
22}
23
24// CreateOutput represents the response body from a Create request.
25const CreateOutput = `
26{
27 "stack": {
28 "id": "16ef0584-4458-41eb-87c8-0dc8d5f66c87",
29 "links": [
30 {
31 "href": "http://168.28.170.117:8004/v1/98606384f58drad0bhdb7d02779549ac/stacks/stackcreated/16ef0584-4458-41eb-87c8-0dc8d5f66c87",
32 "rel": "self"
33 }
34 ]
35 }
36}`
37
38// HandleCreateSuccessfully creates an HTTP handler at `/stacks` on the test handler mux
39// that responds with a `Create` response.
40func HandleCreateSuccessfully(t *testing.T, output string) {
41 th.Mux.HandleFunc("/stacks", func(w http.ResponseWriter, r *http.Request) {
42 th.TestMethod(t, r, "POST")
43 th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
44 th.TestHeader(t, r, "Accept", "application/json")
45 w.WriteHeader(http.StatusCreated)
46 fmt.Fprintf(w, output)
47 })
48}