github.com/gophercloud/gophercloud@v1.11.0/openstack/orchestration/v1/stacktemplates/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/gophercloud/gophercloud/openstack/orchestration/v1/stacktemplates" 7 th "github.com/gophercloud/gophercloud/testhelper" 8 fake "github.com/gophercloud/gophercloud/testhelper/client" 9 ) 10 11 func TestGetTemplate(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 HandleGetSuccessfully(t, GetOutput) 15 16 actual, err := stacktemplates.Get(fake.ServiceClient(), "postman_stack", "16ef0584-4458-41eb-87c8-0dc8d5f66c87").Extract() 17 th.AssertNoErr(t, err) 18 19 expected := GetExpected 20 th.AssertDeepEquals(t, expected, string(actual)) 21 } 22 23 func TestValidateTemplate(t *testing.T) { 24 th.SetupHTTP() 25 defer th.TeardownHTTP() 26 HandleValidateSuccessfully(t, ValidateOutput) 27 28 opts := stacktemplates.ValidateOpts{ 29 Template: `{ 30 "heat_template_version": "2013-05-23", 31 "description": "Simple template to test heat commands", 32 "parameters": { 33 "flavor": { 34 "default": "m1.tiny", 35 "type": "string" 36 } 37 }, 38 "resources": { 39 "hello_world": { 40 "type": "OS::Nova::Server", 41 "properties": { 42 "key_name": "heat_key", 43 "flavor": { 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 := stacktemplates.Validate(fake.ServiceClient(), opts).Extract() 54 th.AssertNoErr(t, err) 55 56 expected := ValidateExpected 57 th.AssertDeepEquals(t, expected, actual) 58 }