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

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/apigw/v2/apigroups"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateV2Group(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  	handleV2GroupCreate(t)
    15  
    16  	actual, err := apigroups.Create(client.ServiceClient(), "9750f26518a54da8bea1a7c41790c26d", createOpts).Extract()
    17  	th.AssertNoErr(t, err)
    18  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    19  }
    20  
    21  func TestGetV2Group(t *testing.T) {
    22  	th.SetupHTTP()
    23  	defer th.TeardownHTTP()
    24  	handleV2GroupGet(t)
    25  
    26  	actual, err := apigroups.Get(client.ServiceClient(), "9750f26518a54da8bea1a7c41790c26d", "1c1acdd2f4d14eb886ecd2370cdb9c1a").Extract()
    27  	th.AssertNoErr(t, err)
    28  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    29  }
    30  
    31  func TestListV2Group(t *testing.T) {
    32  	th.SetupHTTP()
    33  	defer th.TeardownHTTP()
    34  	handleV2GroupList(t)
    35  
    36  	pages, err := apigroups.List(client.ServiceClient(), "9750f26518a54da8bea1a7c41790c26d", apigroups.ListOpts{}).AllPages()
    37  	th.AssertNoErr(t, err)
    38  	actual, err := apigroups.ExtractGroups(pages)
    39  	th.AssertNoErr(t, err)
    40  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    41  }
    42  
    43  func TestUpdateV2Group(t *testing.T) {
    44  	th.SetupHTTP()
    45  	defer th.TeardownHTTP()
    46  	handleV2GroupUpdate(t)
    47  
    48  	actual, err := apigroups.Update(client.ServiceClient(), "9750f26518a54da8bea1a7c41790c26d", "1c1acdd2f4d14eb886ecd2370cdb9c1a", updateOpts).Extract()
    49  	th.AssertNoErr(t, err)
    50  	th.AssertDeepEquals(t, expectedUpdateResponseData, actual)
    51  }
    52  
    53  func TestDeleteV2Group(t *testing.T) {
    54  	th.SetupHTTP()
    55  	defer th.TeardownHTTP()
    56  	handleV2GroupDelete(t)
    57  
    58  	err := apigroups.Delete(client.ServiceClient(), "9750f26518a54da8bea1a7c41790c26d", "1c1acdd2f4d14eb886ecd2370cdb9c1a").ExtractErr()
    59  	th.AssertNoErr(t, err)
    60  }