github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cbr/v3/policies/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 golangsdk "github.com/opentelekomcloud/gophertelekomcloud" 7 "github.com/opentelekomcloud/gophertelekomcloud/openstack/cbr/v3/policies" 8 th "github.com/opentelekomcloud/gophertelekomcloud/testhelper" 9 fake "github.com/opentelekomcloud/gophertelekomcloud/testhelper/client" 10 ) 11 12 func TestCreateV3PolicyMarshall(t *testing.T) { 13 res, err := golangsdk.BuildRequestBody(createOpts, "policy") 14 th.AssertNoErr(t, err) 15 th.AssertJSONEquals(t, expectedRequest, res) 16 } 17 18 func TestCreateV3Policy(t *testing.T) { 19 th.SetupHTTP() 20 defer th.TeardownHTTP() 21 handlePolicyCreation(t) 22 23 actual, err := policies.Create(fake.ServiceClient(), createOpts) 24 th.AssertNoErr(t, err) 25 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 26 } 27 28 func TestDeleteV3Policy(t *testing.T) { 29 th.SetupHTTP() 30 defer th.TeardownHTTP() 31 handlePolicyDeletion(t) 32 33 err := policies.Delete(fake.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22") 34 th.AssertNoErr(t, err) 35 } 36 37 func TestUpdateV3Policy(t *testing.T) { 38 th.SetupHTTP() 39 defer th.TeardownHTTP() 40 handlePolicyUpdate(t) 41 42 updateId := "cbb3ce6f-3332-4e7c-b98e-77290d8471ff" 43 actual, err := policies.Update(fake.ServiceClient(), updateId, updateOpts) 44 th.AssertNoErr(t, err) 45 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 46 }