Jon Perritt | f63c909 | 2015-02-09 11:23:59 -0700 | [diff] [blame] | 1 | package stacktemplates |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | os "github.com/rackspace/gophercloud/openstack/orchestration/v1/stacktemplates" |
| 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 9 | ) |
| 10 | |
| 11 | func TestGetTemplate(t *testing.T) { |
| 12 | th.SetupHTTP() |
| 13 | defer th.TeardownHTTP() |
| 14 | os.HandleGetSuccessfully(t, os.GetOutput) |
| 15 | |
| 16 | actual, err := Get(fake.ServiceClient(), "postman_stack", "16ef0584-4458-41eb-87c8-0dc8d5f66c87").Extract() |
| 17 | th.AssertNoErr(t, err) |
| 18 | |
| 19 | expected := os.GetExpected |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 20 | th.AssertDeepEquals(t, expected, string(actual)) |
Jon Perritt | f63c909 | 2015-02-09 11:23:59 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | func TestValidateTemplate(t *testing.T) { |
| 24 | th.SetupHTTP() |
| 25 | defer th.TeardownHTTP() |
| 26 | os.HandleValidateSuccessfully(t, os.ValidateOutput) |
| 27 | |
| 28 | opts := os.ValidateOpts{ |
Pratik Mallya | 827c03e | 2015-09-17 00:10:47 -0500 | [diff] [blame] | 29 | Template: `{ |
| 30 | "Description": "Simple template to test heat commands", |
| 31 | "Parameters": { |
| 32 | "flavor": { |
| 33 | "Default": "m1.tiny", |
| 34 | "Type": "String", |
| 35 | "NoEcho": "false", |
| 36 | "Description": "", |
| 37 | "Label": "flavor" |
| 38 | } |
| 39 | } |
| 40 | }`, |
Jon Perritt | f63c909 | 2015-02-09 11:23:59 -0700 | [diff] [blame] | 41 | } |
| 42 | actual, err := Validate(fake.ServiceClient(), opts).Extract() |
| 43 | th.AssertNoErr(t, err) |
| 44 | |
| 45 | expected := os.ValidateExpected |
| 46 | th.AssertDeepEquals(t, expected, actual) |
| 47 | } |