Jon Perritt | 7cbb42c | 2015-02-08 21:13:08 -0700 | [diff] [blame^] | 1 | package stackevents |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | "time" |
| 8 | |
| 9 | "github.com/rackspace/gophercloud" |
| 10 | th "github.com/rackspace/gophercloud/testhelper" |
| 11 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 12 | ) |
| 13 | |
| 14 | // FindExpected represents the expected object from a Find request. |
| 15 | var FindExpected = []Event{ |
| 16 | Event{ |
| 17 | ResourceName: "hello_world", |
| 18 | Time: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), |
| 19 | Links: []gophercloud.Link{ |
| 20 | gophercloud.Link{ |
| 21 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 22 | Rel: "self", |
| 23 | }, |
| 24 | gophercloud.Link{ |
| 25 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 26 | Rel: "resource", |
| 27 | }, |
| 28 | gophercloud.Link{ |
| 29 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 30 | Rel: "stack", |
| 31 | }, |
| 32 | }, |
| 33 | LogicalResourceID: "hello_world", |
| 34 | ResourceStatusReason: "state changed", |
| 35 | ResourceStatus: "CREATE_IN_PROGRESS", |
| 36 | PhysicalResourceID: "", |
| 37 | ID: "06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 38 | }, |
| 39 | Event{ |
| 40 | ResourceName: "hello_world", |
| 41 | Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), |
| 42 | Links: []gophercloud.Link{ |
| 43 | gophercloud.Link{ |
| 44 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 45 | Rel: "self", |
| 46 | }, |
| 47 | gophercloud.Link{ |
| 48 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 49 | Rel: "resource", |
| 50 | }, |
| 51 | gophercloud.Link{ |
| 52 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 53 | Rel: "stack", |
| 54 | }, |
| 55 | }, |
| 56 | LogicalResourceID: "hello_world", |
| 57 | ResourceStatusReason: "state changed", |
| 58 | ResourceStatus: "CREATE_COMPLETE", |
| 59 | PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 60 | ID: "93940999-7d40-44ae-8de4-19624e7b8d18", |
| 61 | }, |
| 62 | } |
| 63 | |
| 64 | // FindOutput represents the response body from a Find request. |
| 65 | const FindOutput = ` |
| 66 | { |
| 67 | "events": [ |
| 68 | { |
| 69 | "resource_name": "hello_world", |
| 70 | "event_time": "2015-02-05T21:33:11Z", |
| 71 | "links": [ |
| 72 | { |
| 73 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 74 | "rel": "self" |
| 75 | }, |
| 76 | { |
| 77 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 78 | "rel": "resource" |
| 79 | }, |
| 80 | { |
| 81 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 82 | "rel": "stack" |
| 83 | } |
| 84 | ], |
| 85 | "logical_resource_id": "hello_world", |
| 86 | "resource_status_reason": "state changed", |
| 87 | "resource_status": "CREATE_IN_PROGRESS", |
| 88 | "physical_resource_id": null, |
| 89 | "id": "06feb26f-9298-4a9b-8749-9d770e5d577a" |
| 90 | }, |
| 91 | { |
| 92 | "resource_name": "hello_world", |
| 93 | "event_time": "2015-02-05T21:33:27Z", |
| 94 | "links": [ |
| 95 | { |
| 96 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 97 | "rel": "self" |
| 98 | }, |
| 99 | { |
| 100 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 101 | "rel": "resource" |
| 102 | }, |
| 103 | { |
| 104 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 105 | "rel": "stack" |
| 106 | } |
| 107 | ], |
| 108 | "logical_resource_id": "hello_world", |
| 109 | "resource_status_reason": "state changed", |
| 110 | "resource_status": "CREATE_COMPLETE", |
| 111 | "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 112 | "id": "93940999-7d40-44ae-8de4-19624e7b8d18" |
| 113 | } |
| 114 | ] |
| 115 | }` |
| 116 | |
| 117 | // HandleFindSuccessfully creates an HTTP handler at `/stacks/postman_stack/events` |
| 118 | // on the test handler mux that responds with a `Find` response. |
| 119 | func HandleFindSuccessfully(t *testing.T, output string) { |
| 120 | th.Mux.HandleFunc("/stacks/postman_stack/events", func(w http.ResponseWriter, r *http.Request) { |
| 121 | th.TestMethod(t, r, "GET") |
| 122 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 123 | th.TestHeader(t, r, "Accept", "application/json") |
| 124 | |
| 125 | w.Header().Set("Content-Type", "application/json") |
| 126 | w.WriteHeader(http.StatusOK) |
| 127 | fmt.Fprintf(w, output) |
| 128 | }) |
| 129 | } |
| 130 | |
| 131 | // ListExpected represents the expected object from a List request. |
| 132 | var ListExpected = []Event{ |
| 133 | Event{ |
| 134 | ResourceName: "hello_world", |
| 135 | Time: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), |
| 136 | Links: []gophercloud.Link{ |
| 137 | gophercloud.Link{ |
| 138 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 139 | Rel: "self", |
| 140 | }, |
| 141 | gophercloud.Link{ |
| 142 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 143 | Rel: "resource", |
| 144 | }, |
| 145 | gophercloud.Link{ |
| 146 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 147 | Rel: "stack", |
| 148 | }, |
| 149 | }, |
| 150 | LogicalResourceID: "hello_world", |
| 151 | ResourceStatusReason: "state changed", |
| 152 | ResourceStatus: "CREATE_IN_PROGRESS", |
| 153 | PhysicalResourceID: "", |
| 154 | ID: "06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 155 | }, |
| 156 | Event{ |
| 157 | ResourceName: "hello_world", |
| 158 | Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), |
| 159 | Links: []gophercloud.Link{ |
| 160 | gophercloud.Link{ |
| 161 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 162 | Rel: "self", |
| 163 | }, |
| 164 | gophercloud.Link{ |
| 165 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 166 | Rel: "resource", |
| 167 | }, |
| 168 | gophercloud.Link{ |
| 169 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 170 | Rel: "stack", |
| 171 | }, |
| 172 | }, |
| 173 | LogicalResourceID: "hello_world", |
| 174 | ResourceStatusReason: "state changed", |
| 175 | ResourceStatus: "CREATE_COMPLETE", |
| 176 | PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 177 | ID: "93940999-7d40-44ae-8de4-19624e7b8d18", |
| 178 | }, |
| 179 | } |
| 180 | |
| 181 | // ListOutput represents the response body from a List request. |
| 182 | const ListOutput = ` |
| 183 | { |
| 184 | "events": [ |
| 185 | { |
| 186 | "resource_name": "hello_world", |
| 187 | "event_time": "2015-02-05T21:33:11Z", |
| 188 | "links": [ |
| 189 | { |
| 190 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 191 | "rel": "self" |
| 192 | }, |
| 193 | { |
| 194 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 195 | "rel": "resource" |
| 196 | }, |
| 197 | { |
| 198 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 199 | "rel": "stack" |
| 200 | } |
| 201 | ], |
| 202 | "logical_resource_id": "hello_world", |
| 203 | "resource_status_reason": "state changed", |
| 204 | "resource_status": "CREATE_IN_PROGRESS", |
| 205 | "physical_resource_id": null, |
| 206 | "id": "06feb26f-9298-4a9b-8749-9d770e5d577a" |
| 207 | }, |
| 208 | { |
| 209 | "resource_name": "hello_world", |
| 210 | "event_time": "2015-02-05T21:33:27Z", |
| 211 | "links": [ |
| 212 | { |
| 213 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 214 | "rel": "self" |
| 215 | }, |
| 216 | { |
| 217 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 218 | "rel": "resource" |
| 219 | }, |
| 220 | { |
| 221 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 222 | "rel": "stack" |
| 223 | } |
| 224 | ], |
| 225 | "logical_resource_id": "hello_world", |
| 226 | "resource_status_reason": "state changed", |
| 227 | "resource_status": "CREATE_COMPLETE", |
| 228 | "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 229 | "id": "93940999-7d40-44ae-8de4-19624e7b8d18" |
| 230 | } |
| 231 | ] |
| 232 | }` |
| 233 | |
| 234 | // HandleListSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/events` |
| 235 | // on the test handler mux that responds with a `List` response. |
| 236 | func HandleListSuccessfully(t *testing.T, output string) { |
| 237 | th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/events", func(w http.ResponseWriter, r *http.Request) { |
| 238 | th.TestMethod(t, r, "GET") |
| 239 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 240 | th.TestHeader(t, r, "Accept", "application/json") |
| 241 | |
| 242 | w.Header().Set("Content-Type", "application/json") |
| 243 | r.ParseForm() |
| 244 | marker := r.Form.Get("marker") |
| 245 | switch marker { |
| 246 | case "": |
| 247 | fmt.Fprintf(w, output) |
| 248 | case "93940999-7d40-44ae-8de4-19624e7b8d18": |
| 249 | fmt.Fprintf(w, `{"events":[]}`) |
| 250 | default: |
| 251 | t.Fatalf("Unexpected marker: [%s]", marker) |
| 252 | } |
| 253 | }) |
| 254 | } |
| 255 | |
| 256 | // ListResourceEventsExpected represents the expected object from a ListResourceEvents request. |
| 257 | var ListResourceEventsExpected = []Event{ |
| 258 | Event{ |
| 259 | ResourceName: "hello_world", |
| 260 | Time: time.Date(2015, 2, 5, 21, 33, 11, 0, time.UTC), |
| 261 | Links: []gophercloud.Link{ |
| 262 | gophercloud.Link{ |
| 263 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 264 | Rel: "self", |
| 265 | }, |
| 266 | gophercloud.Link{ |
| 267 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 268 | Rel: "resource", |
| 269 | }, |
| 270 | gophercloud.Link{ |
| 271 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 272 | Rel: "stack", |
| 273 | }, |
| 274 | }, |
| 275 | LogicalResourceID: "hello_world", |
| 276 | ResourceStatusReason: "state changed", |
| 277 | ResourceStatus: "CREATE_IN_PROGRESS", |
| 278 | PhysicalResourceID: "", |
| 279 | ID: "06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 280 | }, |
| 281 | Event{ |
| 282 | ResourceName: "hello_world", |
| 283 | Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), |
| 284 | Links: []gophercloud.Link{ |
| 285 | gophercloud.Link{ |
| 286 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 287 | Rel: "self", |
| 288 | }, |
| 289 | gophercloud.Link{ |
| 290 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 291 | Rel: "resource", |
| 292 | }, |
| 293 | gophercloud.Link{ |
| 294 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 295 | Rel: "stack", |
| 296 | }, |
| 297 | }, |
| 298 | LogicalResourceID: "hello_world", |
| 299 | ResourceStatusReason: "state changed", |
| 300 | ResourceStatus: "CREATE_COMPLETE", |
| 301 | PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 302 | ID: "93940999-7d40-44ae-8de4-19624e7b8d18", |
| 303 | }, |
| 304 | } |
| 305 | |
| 306 | // ListResourceEventsOutput represents the response body from a ListResourceEvents request. |
| 307 | const ListResourceEventsOutput = ` |
| 308 | { |
| 309 | "events": [ |
| 310 | { |
| 311 | "resource_name": "hello_world", |
| 312 | "event_time": "2015-02-05T21:33:11Z", |
| 313 | "links": [ |
| 314 | { |
| 315 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/06feb26f-9298-4a9b-8749-9d770e5d577a", |
| 316 | "rel": "self" |
| 317 | }, |
| 318 | { |
| 319 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 320 | "rel": "resource" |
| 321 | }, |
| 322 | { |
| 323 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 324 | "rel": "stack" |
| 325 | } |
| 326 | ], |
| 327 | "logical_resource_id": "hello_world", |
| 328 | "resource_status_reason": "state changed", |
| 329 | "resource_status": "CREATE_IN_PROGRESS", |
| 330 | "physical_resource_id": null, |
| 331 | "id": "06feb26f-9298-4a9b-8749-9d770e5d577a" |
| 332 | }, |
| 333 | { |
| 334 | "resource_name": "hello_world", |
| 335 | "event_time": "2015-02-05T21:33:27Z", |
| 336 | "links": [ |
| 337 | { |
| 338 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 339 | "rel": "self" |
| 340 | }, |
| 341 | { |
| 342 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 343 | "rel": "resource" |
| 344 | }, |
| 345 | { |
| 346 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 347 | "rel": "stack" |
| 348 | } |
| 349 | ], |
| 350 | "logical_resource_id": "hello_world", |
| 351 | "resource_status_reason": "state changed", |
| 352 | "resource_status": "CREATE_COMPLETE", |
| 353 | "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 354 | "id": "93940999-7d40-44ae-8de4-19624e7b8d18" |
| 355 | } |
| 356 | ] |
| 357 | }` |
| 358 | |
| 359 | // HandleListResourceEventsSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events` |
| 360 | // on the test handler mux that responds with a `ListResourceEvents` response. |
| 361 | func HandleListResourceEventsSuccessfully(t *testing.T, output string) { |
| 362 | th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events", func(w http.ResponseWriter, r *http.Request) { |
| 363 | th.TestMethod(t, r, "GET") |
| 364 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 365 | th.TestHeader(t, r, "Accept", "application/json") |
| 366 | |
| 367 | w.Header().Set("Content-Type", "application/json") |
| 368 | r.ParseForm() |
| 369 | marker := r.Form.Get("marker") |
| 370 | switch marker { |
| 371 | case "": |
| 372 | fmt.Fprintf(w, output) |
| 373 | case "93940999-7d40-44ae-8de4-19624e7b8d18": |
| 374 | fmt.Fprintf(w, `{"events":[]}`) |
| 375 | default: |
| 376 | t.Fatalf("Unexpected marker: [%s]", marker) |
| 377 | } |
| 378 | }) |
| 379 | } |
| 380 | |
| 381 | // GetExpected represents the expected object from a Get request. |
| 382 | var GetExpected = &Event{ |
| 383 | ResourceName: "hello_world", |
| 384 | Time: time.Date(2015, 2, 5, 21, 33, 27, 0, time.UTC), |
| 385 | Links: []gophercloud.Link{ |
| 386 | gophercloud.Link{ |
| 387 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 388 | Rel: "self", |
| 389 | }, |
| 390 | gophercloud.Link{ |
| 391 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 392 | Rel: "resource", |
| 393 | }, |
| 394 | gophercloud.Link{ |
| 395 | Href: "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 396 | Rel: "stack", |
| 397 | }, |
| 398 | }, |
| 399 | LogicalResourceID: "hello_world", |
| 400 | ResourceStatusReason: "state changed", |
| 401 | ResourceStatus: "CREATE_COMPLETE", |
| 402 | PhysicalResourceID: "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 403 | ID: "93940999-7d40-44ae-8de4-19624e7b8d18", |
| 404 | } |
| 405 | |
| 406 | // GetOutput represents the response body from a Get request. |
| 407 | const GetOutput = ` |
| 408 | { |
| 409 | "event":{ |
| 410 | "resource_name": "hello_world", |
| 411 | "event_time": "2015-02-05T21:33:27Z", |
| 412 | "links": [ |
| 413 | { |
| 414 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world/events/93940999-7d40-44ae-8de4-19624e7b8d18", |
| 415 | "rel": "self" |
| 416 | }, |
| 417 | { |
| 418 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b/resources/hello_world", |
| 419 | "rel": "resource" |
| 420 | }, |
| 421 | { |
| 422 | "href": "http://166.78.160.107:8004/v1/98606384f58d4ad0b3db7d0d779549ac/stacks/postman_stack/5f57cff9-93fc-424e-9f78-df0515e7f48b", |
| 423 | "rel": "stack" |
| 424 | } |
| 425 | ], |
| 426 | "logical_resource_id": "hello_world", |
| 427 | "resource_status_reason": "state changed", |
| 428 | "resource_status": "CREATE_COMPLETE", |
| 429 | "physical_resource_id": "49181cd6-169a-4130-9455-31185bbfc5bf", |
| 430 | "id": "93940999-7d40-44ae-8de4-19624e7b8d18" |
| 431 | } |
| 432 | }` |
| 433 | |
| 434 | // HandleGetSuccessfully creates an HTTP handler at `/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events/93940999-7d40-44ae-8de4-19624e7b8d18` |
| 435 | // on the test handler mux that responds with a `Get` response. |
| 436 | func HandleGetSuccessfully(t *testing.T, output string) { |
| 437 | th.Mux.HandleFunc("/stacks/hello_world/49181cd6-169a-4130-9455-31185bbfc5bf/resources/my_resource/events/93940999-7d40-44ae-8de4-19624e7b8d18", func(w http.ResponseWriter, r *http.Request) { |
| 438 | th.TestMethod(t, r, "GET") |
| 439 | th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) |
| 440 | th.TestHeader(t, r, "Accept", "application/json") |
| 441 | |
| 442 | w.Header().Set("Content-Type", "application/json") |
| 443 | w.WriteHeader(http.StatusOK) |
| 444 | fmt.Fprintf(w, output) |
| 445 | }) |
| 446 | } |