github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/autoscaling/v1/lifecyclehooks/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/autoscaling/v1/lifecyclehooks"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateLifecycleHook(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  	handleLifeCycleHookCreate(t)
    15  
    16  	actual, err := lifecyclehooks.Create(client.ServiceClient(), createOpts, "50ed20b8-9853-4668-a71c-c8c15b5cb85f").Extract()
    17  	th.AssertNoErr(t, err)
    18  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    19  }
    20  
    21  func TestGetLifecycleHook(t *testing.T) {
    22  	th.SetupHTTP()
    23  	defer th.TeardownHTTP()
    24  	handleLifeCycleHookGet(t)
    25  
    26  	actual, err := lifecyclehooks.Get(client.ServiceClient(), "50ed20b8-9853-4668-a71c-c8c15b5cb85f", "test-hook").Extract()
    27  	th.AssertNoErr(t, err)
    28  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    29  }
    30  
    31  func TestListLifecycleHook(t *testing.T) {
    32  	th.SetupHTTP()
    33  	defer th.TeardownHTTP()
    34  	handleLifeCycleHookList(t)
    35  
    36  	actual, err := lifecyclehooks.List(client.ServiceClient(), "50ed20b8-9853-4668-a71c-c8c15b5cb85f").Extract()
    37  	th.AssertNoErr(t, err)
    38  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    39  }
    40  
    41  func TestUpdateLifecycleHook(t *testing.T) {
    42  	th.SetupHTTP()
    43  	defer th.TeardownHTTP()
    44  	handleLifeCycleHookUpdate(t)
    45  
    46  	actual, err := lifecyclehooks.Update(client.ServiceClient(), updateOpts, "50ed20b8-9853-4668-a71c-c8c15b5cb85f", "test-hook").Extract()
    47  	th.AssertNoErr(t, err)
    48  	th.AssertDeepEquals(t, expectedUpdateResponseData, actual)
    49  }
    50  
    51  func TestDeleteLifecycleHook(t *testing.T) {
    52  	th.SetupHTTP()
    53  	defer th.TeardownHTTP()
    54  	handleLifeCycleHookDelete(t)
    55  
    56  	err := lifecyclehooks.Delete(client.ServiceClient(), "50ed20b8-9853-4668-a71c-c8c15b5cb85f", "test-hook").ExtractErr()
    57  	th.AssertNoErr(t, err)
    58  }