blob: 42663dc40633734cae0a081526736d1a1486f962 [file] [log] [blame]
Jon Perrittf799b942015-02-09 11:23:28 -07001package stacktemplates
2
3import (
4 "testing"
5
Jon Perritt27249f42016-02-18 10:35:59 -06006 th "github.com/gophercloud/gophercloud/testhelper"
7 fake "github.com/gophercloud/gophercloud/testhelper/client"
Jon Perrittf799b942015-02-09 11:23:28 -07008)
9
10func 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 Mallya827c03e2015-09-17 00:10:47 -050019 th.AssertDeepEquals(t, expected, string(actual))
Jon Perrittf799b942015-02-09 11:23:28 -070020}
21
22func TestValidateTemplate(t *testing.T) {
23 th.SetupHTTP()
24 defer th.TeardownHTTP()
25 HandleValidateSuccessfully(t, ValidateOutput)
26
27 opts := ValidateOpts{
Pratik Mallya827c03e2015-09-17 00:10:47 -050028 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 Perrittf799b942015-02-09 11:23:28 -070051 }
52 actual, err := Validate(fake.ServiceClient(), opts).Extract()
53 th.AssertNoErr(t, err)
54
55 expected := ValidateExpected
56 th.AssertDeepEquals(t, expected, actual)
57}