Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 1 | package stacktemplates |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame] | 6 | th "github.com/gophercloud/gophercloud/testhelper" |
| 7 | fake "github.com/gophercloud/gophercloud/testhelper/client" |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 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 |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 19 | th.AssertDeepEquals(t, expected, string(actual)) |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | func TestValidateTemplate(t *testing.T) { |
| 23 | th.SetupHTTP() |
| 24 | defer th.TeardownHTTP() |
| 25 | HandleValidateSuccessfully(t, ValidateOutput) |
| 26 | |
| 27 | opts := ValidateOpts{ |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 28 | Template: `{ |
| 29 | "heat_template_version": "2013-05-23", |
| 30 | "description": "Simple template to test heat commands", |
| 31 | "parameters": { |
| 32 | "flavor": { |
| 33 | "default": "m1.tiny", |
| 34 | "type": "string" |
| 35 | } |
| 36 | }, |
| 37 | "resources": { |
| 38 | "hello_world": { |
| 39 | "type": "OS::Nova::Server", |
| 40 | "properties": { |
| 41 | "key_name": "heat_key", |
| 42 | "flavor": { |
| 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 | }`, |
Jon Perritt | f799b94 | 2015-02-09 11:23:28 -0700 | [diff] [blame] | 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 | } |