github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/rts/v1/stacks/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk" 7 "github.com/huaweicloud/golangsdk/openstack/rts/v1/stacks" 8 th "github.com/huaweicloud/golangsdk/testhelper" 9 fake "github.com/huaweicloud/golangsdk/testhelper/client" 10 ) 11 12 func TestCreateStack(t *testing.T) { 13 th.SetupHTTP() 14 defer th.TeardownHTTP() 15 HandleCreateSuccessfully(t, CreateOutput) 16 template := new(stacks.Template) 17 template.Bin = []byte(` 18 { 19 "heat_template_version": "2013-05-23", 20 "description": "Simple template to test heat commands", 21 "parameters": { 22 "flavor": { 23 "default": "m1.tiny", 24 "type": "string" 25 } 26 } 27 }`) 28 createOpts := stacks.CreateOpts{ 29 Name: "stackcreated", 30 Timeout: 60, 31 TemplateOpts: template, 32 DisableRollback: golangsdk.Disabled, 33 } 34 actual, err := stacks.Create(fake.ServiceClient(), createOpts).Extract() 35 th.AssertNoErr(t, err) 36 37 expected := CreateExpected 38 th.AssertDeepEquals(t, expected, actual) 39 } 40 41 func TestListStack(t *testing.T) { 42 th.SetupHTTP() 43 defer th.TeardownHTTP() 44 HandleListSuccessfully(t, FullListOutput) 45 46 actual, err := stacks.List(fake.ServiceClient(), stacks.ListOpts{}) 47 th.AssertDeepEquals(t, ListExpected, actual) 48 th.AssertNoErr(t, err) 49 } 50 51 func TestGetStack(t *testing.T) { 52 th.SetupHTTP() 53 defer th.TeardownHTTP() 54 HandleGetSuccessfully(t, GetOutput) 55 56 actual, err := stacks.Get(fake.ServiceClient(), "postman_stack").Extract() 57 th.AssertNoErr(t, err) 58 59 expected := GetExpected 60 th.AssertDeepEquals(t, expected, actual) 61 } 62 63 func TestUpdateStack(t *testing.T) { 64 th.SetupHTTP() 65 defer th.TeardownHTTP() 66 HandleUpdateSuccessfully(t) 67 68 template := new(stacks.Template) 69 template.Bin = []byte(` 70 { 71 "heat_template_version": "2013-05-23", 72 "description": "Simple template to test heat commands", 73 "parameters": { 74 "flavor": { 75 "default": "m1.tiny", 76 "type": "string" 77 } 78 } 79 }`) 80 updateOpts := stacks.UpdateOpts{ 81 TemplateOpts: template, 82 } 83 err := stacks.Update(fake.ServiceClient(), "golangsdk-test-stack-2", "db6977b2-27aa-4775-9ae7-6213212d4ada", updateOpts).ExtractErr() 84 th.AssertNoErr(t, err) 85 } 86 87 func TestDeleteStack(t *testing.T) { 88 th.SetupHTTP() 89 defer th.TeardownHTTP() 90 HandleDeleteSuccessfully(t) 91 92 err := stacks.Delete(fake.ServiceClient(), "golangsdk-test-stack-2", "db6977b2-27aa-4775-9ae7-6213212d4ada").ExtractErr() 93 th.AssertNoErr(t, err) 94 }