blob: d31c4ac9a2d022213f48a3ef3bd616d197effd67 [file] [log] [blame]
Jon Perrittf799b942015-02-09 11:23:28 -07001package stacktemplates
2
3import (
4 "testing"
5
6 th "github.com/rackspace/gophercloud/testhelper"
7 fake "github.com/rackspace/gophercloud/testhelper/client"
8)
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
19 th.AssertDeepEquals(t, expected, actual)
20}
21
22func 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}