Jon Perritt | 4a5c849 | 2015-02-03 13:13:59 -0700 | [diff] [blame] | 1 | package stacks |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | th "github.com/rackspace/gophercloud/testhelper" |
| 7 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 8 | ) |
| 9 | |
| 10 | func TestCreateStack(t *testing.T) { |
| 11 | th.SetupHTTP() |
| 12 | defer th.TeardownHTTP() |
| 13 | HandleCreateSuccessfully(t, CreateOutput) |
| 14 | |
| 15 | createOpts := CreateOpts{ |
| 16 | Name: "stackcreated", |
| 17 | Timeout: 60, |
| 18 | Template: ` |
| 19 | { |
| 20 | "stack_name": "postman_stack", |
| 21 | "template": { |
| 22 | "heat_template_version": "2013-05-23", |
| 23 | "description": "Simple template to test heat commands", |
| 24 | "parameters": { |
| 25 | "flavor": { |
| 26 | "default": "m1.tiny", |
| 27 | "type": "string" |
| 28 | } |
| 29 | }, |
| 30 | "resources": { |
| 31 | "hello_world": { |
| 32 | "type":"OS::Nova::Server", |
| 33 | "properties": { |
| 34 | "key_name": "heat_key", |
| 35 | "flavor": { |
| 36 | "get_param": "flavor" |
| 37 | }, |
| 38 | "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", |
| 39 | "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n" |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | }`, |
| 45 | DisableRollback: Disable, |
| 46 | } |
| 47 | actual, err := Create(fake.ServiceClient(), createOpts).Extract() |
| 48 | th.AssertNoErr(t, err) |
| 49 | |
| 50 | expected := CreateExpected |
| 51 | th.AssertDeepEquals(t, expected, actual) |
| 52 | } |