blob: d4006c476d5d3aeda17988e6a2769c2c5f1dda3c [file] [log] [blame]
Jon Perrittf63c9092015-02-09 11:23:59 -07001package stacktemplates
2
3import (
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
11func 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
20 th.AssertDeepEquals(t, expected, actual)
21}
22
23func TestValidateTemplate(t *testing.T) {
24 th.SetupHTTP()
25 defer th.TeardownHTTP()
26 os.HandleValidateSuccessfully(t, os.ValidateOutput)
27
28 opts := os.ValidateOpts{
29 Template: map[string]interface{}{
30 "heat_template_version": "2013-05-23",
31 "description": "Simple template to test heat commands",
32 "parameters": map[string]interface{}{
33 "flavor": map[string]interface{}{
34 "default": "m1.tiny",
35 "type": "string",
36 },
37 },
38 "resources": map[string]interface{}{
39 "hello_world": map[string]interface{}{
40 "type": "OS::Nova::Server",
41 "properties": map[string]interface{}{
42 "key_name": "heat_key",
43 "flavor": map[string]interface{}{
44 "get_param": "flavor",
45 },
46 "image": "ad091b52-742f-469e-8f3c-fd81cadf0743",
47 "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n",
48 },
49 },
50 },
51 },
52 }
53 actual, err := Validate(fake.ServiceClient(), opts).Extract()
54 th.AssertNoErr(t, err)
55
56 expected := os.ValidateExpected
57 th.AssertDeepEquals(t, expected, actual)
58}