Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 1 | package stacktemplates |
| 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 TestGetTemplate(t *testing.T) { |
| 11 | th.SetupHTTP() |
| 12 | defer th.TeardownHTTP() |
| 13 | HandleGetSuccessfully(t, GetOutput) |
| 14 | |
| 15 | actual, err := Get(fake.ServiceClient(), "postman_stack", "16ef0584-4458-41eb-87c8-0dc8d5f66c87").Extract() |
| 16 | th.AssertNoErr(t, err) |
| 17 | |
| 18 | expected := GetExpected |
| 19 | th.AssertDeepEquals(t, expected, actual) |
| 20 | } |
| 21 | |
| 22 | func TestValidateTemplate(t *testing.T) { |
| 23 | th.SetupHTTP() |
| 24 | defer th.TeardownHTTP() |
| 25 | HandleValidateSuccessfully(t, ValidateOutput) |
| 26 | |
| 27 | opts := ValidateOpts{ |
| 28 | Template: map[string]interface{}{ |
| 29 | "heat_template_version": "2013-05-23", |
| 30 | "description": "Simple template to test heat commands", |
| 31 | "parameters": map[string]interface{}{ |
| 32 | "flavor": map[string]interface{}{ |
| 33 | "default": "m1.tiny", |
| 34 | "type": "string", |
| 35 | }, |
| 36 | }, |
| 37 | "resources": map[string]interface{}{ |
| 38 | "hello_world": map[string]interface{}{ |
| 39 | "type": "OS::Nova::Server", |
| 40 | "properties": map[string]interface{}{ |
| 41 | "key_name": "heat_key", |
| 42 | "flavor": map[string]interface{}{ |
| 43 | "get_param": "flavor", |
| 44 | }, |
| 45 | "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", |
| 46 | "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n", |
| 47 | }, |
| 48 | }, |
| 49 | }, |
| 50 | }, |
| 51 | } |
| 52 | actual, err := Validate(fake.ServiceClient(), opts).Extract() |
| 53 | th.AssertNoErr(t, err) |
| 54 | |
| 55 | expected := ValidateExpected |
| 56 | th.AssertDeepEquals(t, expected, actual) |
| 57 | } |