github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cbr/v3/policies/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/cbr/v3/policies"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateV3PolicyMarshall(t *testing.T) {
    12  	res, err := createOpts.ToPolicyCreateMap()
    13  	th.AssertNoErr(t, err)
    14  	th.AssertJSONEquals(t, expectedRequest, res)
    15  }
    16  
    17  func TestCreateV3Policy(t *testing.T) {
    18  	th.SetupHTTP()
    19  	defer th.TeardownHTTP()
    20  	handlePolicyCreation(t)
    21  
    22  	actual, err := policies.Create(client.ServiceClient(), createOpts).Extract()
    23  	th.AssertNoErr(t, err)
    24  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    25  }
    26  
    27  func TestDeleteV3Policy(t *testing.T) {
    28  	th.SetupHTTP()
    29  	defer th.TeardownHTTP()
    30  	handlePolicyDeletion(t)
    31  
    32  	err := policies.Delete(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").ExtractErr()
    33  	th.AssertNoErr(t, err)
    34  }
    35  
    36  func TestUpdateV3Policy(t *testing.T) {
    37  	th.SetupHTTP()
    38  	defer th.TeardownHTTP()
    39  	handlePolicyUpdate(t)
    40  
    41  	updateId := "cbb3ce6f-3332-4e7c-b98e-77290d8471ff"
    42  	actual, err := policies.Update(client.ServiceClient(), updateId, updateOpts).Extract()
    43  	th.AssertNoErr(t, err)
    44  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    45  }
    46  
    47  func TestGetV3Policy(t *testing.T) {
    48  	th.SetupHTTP()
    49  	defer th.TeardownHTTP()
    50  	handlePolicyGet(t)
    51  
    52  	actual, err := policies.Get(client.ServiceClient(), "d32019d3-bc6e-4319-9c1d-6722fc136a22").Extract()
    53  	th.AssertNoErr(t, err)
    54  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    55  }
    56  
    57  func TestListV3Policy(t *testing.T) {
    58  	th.SetupHTTP()
    59  	defer th.TeardownHTTP()
    60  	handlePolicyList(t)
    61  
    62  	pages, err := policies.List(client.ServiceClient(), policies.ListOpts{}).AllPages()
    63  	th.AssertNoErr(t, err)
    64  	actual, err := policies.ExtractPolicies(pages)
    65  	th.AssertNoErr(t, err)
    66  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    67  }