github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/orchestration/v1/stacktemplates/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/vnpaycloud-console/gophercloud/v2/openstack/orchestration/v1/stacktemplates" 8 th "github.com/vnpaycloud-console/gophercloud/v2/testhelper" 9 fake "github.com/vnpaycloud-console/gophercloud/v2/testhelper/client" 10 ) 11 12 func TestGetTemplate(t *testing.T) { 13 th.SetupHTTP() 14 defer th.TeardownHTTP() 15 HandleGetSuccessfully(t, GetOutput) 16 17 actual, err := stacktemplates.Get(context.TODO(), fake.ServiceClient(), "postman_stack", "16ef0584-4458-41eb-87c8-0dc8d5f66c87").Extract() 18 th.AssertNoErr(t, err) 19 20 expected := GetExpected 21 th.AssertDeepEquals(t, expected, string(actual)) 22 } 23 24 func TestValidateTemplate(t *testing.T) { 25 th.SetupHTTP() 26 defer th.TeardownHTTP() 27 HandleValidateSuccessfully(t, ValidateOutput) 28 29 opts := stacktemplates.ValidateOpts{ 30 Template: `{ 31 "heat_template_version": "2013-05-23", 32 "description": "Simple template to test heat commands", 33 "parameters": { 34 "flavor": { 35 "default": "m1.tiny", 36 "type": "string" 37 } 38 }, 39 "resources": { 40 "hello_world": { 41 "type": "OS::Nova::Server", 42 "properties": { 43 "key_name": "heat_key", 44 "flavor": { 45 "get_param": "flavor" 46 }, 47 "image": "ad091b52-742f-469e-8f3c-fd81cadf0743", 48 "user_data": "#!/bin/bash -xv\necho \"hello world\" > /root/hello-world.txt\n" 49 } 50 } 51 } 52 }`, 53 } 54 actual, err := stacktemplates.Validate(context.TODO(), fake.ServiceClient(), opts).Extract() 55 th.AssertNoErr(t, err) 56 57 expected := ValidateExpected 58 th.AssertDeepEquals(t, expected, actual) 59 }