github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/channels/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/apigw/v2/channels"
     7  
     8  	th "github.com/huaweicloud/golangsdk/testhelper"
     9  	"github.com/huaweicloud/golangsdk/testhelper/client"
    10  )
    11  
    12  func TestCreateV2VpcChannel(t *testing.T) {
    13  	th.SetupHTTP()
    14  	defer th.TeardownHTTP()
    15  	handleV2VpcChannelCreate(t)
    16  
    17  	actual, err := channels.Create(client.ServiceClient(), "b510b8e8ef1442c0a94cdfc551af0ec3",
    18  		createOpts).Extract()
    19  	th.AssertNoErr(t, err)
    20  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    21  }
    22  
    23  func TestGetV2VpcChannel(t *testing.T) {
    24  	th.SetupHTTP()
    25  	defer th.TeardownHTTP()
    26  	handleV2VpcChannelGet(t)
    27  
    28  	actual, err := channels.Get(client.ServiceClient(), "b510b8e8ef1442c0a94cdfc551af0ec3",
    29  		"328d1d563eba4ff084533188b84b9f8d").Extract()
    30  	th.AssertNoErr(t, err)
    31  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    32  }
    33  
    34  func TestListV2VpcChannel(t *testing.T) {
    35  	th.SetupHTTP()
    36  	defer th.TeardownHTTP()
    37  	handleV2VpcChannelList(t)
    38  
    39  	pages, err := channels.List(client.ServiceClient(), "b510b8e8ef1442c0a94cdfc551af0ec3",
    40  		channels.ListOpts{}).AllPages()
    41  	th.AssertNoErr(t, err)
    42  	actual, err := channels.ExtractChannels(pages)
    43  	th.AssertNoErr(t, err)
    44  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    45  }
    46  
    47  func TestUpdateV2VpcChannel(t *testing.T) {
    48  	th.SetupHTTP()
    49  	defer th.TeardownHTTP()
    50  	handleV2VpcChannelUpdate(t)
    51  
    52  	actual, err := channels.Update(client.ServiceClient(), "b510b8e8ef1442c0a94cdfc551af0ec3",
    53  		"328d1d563eba4ff084533188b84b9f8d", createOpts).Extract()
    54  	th.AssertNoErr(t, err)
    55  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    56  }
    57  
    58  func TestDeleteV2VpcChannel(t *testing.T) {
    59  	th.SetupHTTP()
    60  	defer th.TeardownHTTP()
    61  	handleV2VpcChannelDelete(t)
    62  
    63  	err := channels.Delete(client.ServiceClient(), "b510b8e8ef1442c0a94cdfc551af0ec3",
    64  		"328d1d563eba4ff084533188b84b9f8d").ExtractErr()
    65  	th.AssertNoErr(t, err)
    66  }