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

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/mrs/v2/jobs"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateV2Job(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  	handleV2JobCreate(t)
    15  
    16  	actual, err := jobs.Create(client.ServiceClient(), "986416ea-e26b-40f1-b371-cd7be87376a2", createOpts).Extract()
    17  	th.AssertNoErr(t, err)
    18  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    19  }
    20  
    21  func TestGetV2Job(t *testing.T) {
    22  	th.SetupHTTP()
    23  	defer th.TeardownHTTP()
    24  	handleV2JobGet(t)
    25  
    26  	actual, err := jobs.Get(client.ServiceClient(), "986416ea-e26b-40f1-b371-cd7be87376a2",
    27  		"3c0cf394-5da2-46a7-92df-795d998edea7").Extract()
    28  	th.AssertNoErr(t, err)
    29  	th.AssertDeepEquals(t, expectedGetResponseData, actual)
    30  }
    31  
    32  func TestListV2Job(t *testing.T) {
    33  	th.SetupHTTP()
    34  	defer th.TeardownHTTP()
    35  	handleV2JobList(t)
    36  
    37  	pages, err := jobs.List(client.ServiceClient(), "986416ea-e26b-40f1-b371-cd7be87376a2", jobs.ListOpts{}).AllPages()
    38  	th.AssertNoErr(t, err)
    39  	actual, err := jobs.ExtractJobs(pages)
    40  	th.AssertNoErr(t, err)
    41  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    42  }
    43  
    44  func TestDeleteV2Job(t *testing.T) {
    45  	th.SetupHTTP()
    46  	defer th.TeardownHTTP()
    47  	handleV2JobDelete(t)
    48  
    49  	err := jobs.Delete(client.ServiceClient(), "986416ea-e26b-40f1-b371-cd7be87376a2", deleteOpts).ExtractErr()
    50  	th.AssertNoErr(t, err)
    51  }