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

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/apigw/v2/apis"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateV2API(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  	handleV2APICreate(t)
    15  
    16  	actual, err := apis.Create(client.ServiceClient(), "33fc92ffb7e749df952ecc7729d972bc",
    17  		createOpts).Extract()
    18  	th.AssertNoErr(t, err)
    19  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    20  }
    21  
    22  func TestGetV2API(t *testing.T) {
    23  	th.SetupHTTP()
    24  	defer th.TeardownHTTP()
    25  	handleV2APIGet(t)
    26  
    27  	actual, err := apis.Get(client.ServiceClient(), "33fc92ffb7e749df952ecc7729d972bc",
    28  		"cded6d80fc9f442c9842eaf854f10525").Extract()
    29  	th.AssertNoErr(t, err)
    30  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    31  }
    32  
    33  func TestListV2API(t *testing.T) {
    34  	th.SetupHTTP()
    35  	defer th.TeardownHTTP()
    36  	handleV2APIList(t)
    37  
    38  	pages, err := apis.List(client.ServiceClient(), "33fc92ffb7e749df952ecc7729d972bc",
    39  		listOpts).AllPages()
    40  	th.AssertNoErr(t, err)
    41  	actual, err := apis.ExtractApis(pages)
    42  	th.AssertNoErr(t, err)
    43  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    44  }
    45  
    46  func TestUpdateV2API(t *testing.T) {
    47  	th.SetupHTTP()
    48  	defer th.TeardownHTTP()
    49  	handleV2APIUpdate(t)
    50  
    51  	actual, err := apis.Update(client.ServiceClient(), "33fc92ffb7e749df952ecc7729d972bc",
    52  		"cded6d80fc9f442c9842eaf854f10525", createOpts).Extract()
    53  	th.AssertNoErr(t, err)
    54  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    55  }
    56  
    57  func TestDeleteV2API(t *testing.T) {
    58  	th.SetupHTTP()
    59  	defer th.TeardownHTTP()
    60  	handleV2APIDelete(t)
    61  
    62  	err := apis.Delete(client.ServiceClient(), "33fc92ffb7e749df952ecc7729d972bc",
    63  		"cded6d80fc9f442c9842eaf854f10525").ExtractErr()
    64  	th.AssertNoErr(t, err)
    65  }