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

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/rts/v1/softwaredeployment"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	fake "github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateSoftwareDeployment(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  	HandleCreateSuccessfully(t, CreateOutput)
    15  
    16  	createOpts := softwaredeployment.CreateOpts{
    17  		ConfigId:     "031e3891-d183-4f8e-a836-589a5dce541c",
    18  		ServerId:     "b7653627-9b2a-4b61-b18f-e20ea88ee924",
    19  		TenantId:     "17fbda95add24720a4038ba4b1c705ed",
    20  		Status:       "IN_PROGRESS",
    21  		Action:       "CREATE",
    22  		StatusReason: "Deploy data available",
    23  	}
    24  
    25  	actual, err := softwaredeployment.Create(fake.ServiceClient(), createOpts).Extract()
    26  	th.AssertNoErr(t, err)
    27  	expected := CreateExpected
    28  	th.CheckDeepEquals(t, expected, actual)
    29  }
    30  
    31  func TestListSoftwareDeployment(t *testing.T) {
    32  	th.SetupHTTP()
    33  	defer th.TeardownHTTP()
    34  	HandleListSuccessfully(t, ListOutput)
    35  
    36  	listOpts := softwaredeployment.ListOpts{}
    37  	actual, err := softwaredeployment.List(fake.ServiceClient(), listOpts)
    38  
    39  	th.AssertNoErr(t, err)
    40  	expected := ListExpected
    41  	th.CheckDeepEquals(t, expected, actual)
    42  }
    43  
    44  func TestGetSoftwareDeployment(t *testing.T) {
    45  	th.SetupHTTP()
    46  	defer th.TeardownHTTP()
    47  	HandleGetSuccessfully(t, GetOutput)
    48  	actual, err := softwaredeployment.Get(fake.ServiceClient(), "43489279-7b12-4fc5-90ed-320f29e89419").Extract()
    49  
    50  	th.AssertNoErr(t, err)
    51  	expected := GetExpected
    52  	th.CheckDeepEquals(t, expected, actual)
    53  }
    54  
    55  func TestUpdateSoftwareDeployment(t *testing.T) {
    56  	th.SetupHTTP()
    57  	defer th.TeardownHTTP()
    58  	HandleUpdateSuccessfully(t, UpdateOutput)
    59  	ouput := map[string]interface{}{
    60  		"deploy_stdout":      "Writing to /tmp/baaaaa\nWritten to /tmp/baaaaa\n",
    61  		"deploy_stderr":      "+ echo Writing to /tmp/baaaaa\n+ echo fooooo\n+ cat /tmp/baaaaa\n+ echo -n The file /tmp/baaaaa contains fooooo for server ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5 during CREATE\n+ echo Written to /tmp/baaaaa\n+ echo Output to stderr\nOutput to stderr\n",
    62  		"deploy_status_code": "0", "result": "The file /tmp/baaaaa contains fooooo for server ec14c864-096e-4e27-bb8a-2c2b4dc6f3f5 during CREATE"}
    63  	updateOpts := softwaredeployment.UpdateOpts{
    64  		Status:       "COMPLETE",
    65  		ConfigId:     "a6ff3598-f2e0-4111-81b0-aa3e1cac2529",
    66  		OutputValues: ouput,
    67  		StatusReason: "Outputs received"}
    68  	actual, err := softwaredeployment.Update(fake.ServiceClient(), "43489279-7b12-4fc5-90ed-320f29e89419", updateOpts).Extract()
    69  
    70  	th.AssertNoErr(t, err)
    71  	expected := UpdateExpected
    72  	th.CheckDeepEquals(t, expected, actual)
    73  }
    74  
    75  func TestDeleteSoftwareConfig(t *testing.T) {
    76  	th.SetupHTTP()
    77  	defer th.TeardownHTTP()
    78  	HandleDeleteSuccessfully(t)
    79  
    80  	err := softwaredeployment.Delete(fake.ServiceClient(), "43489279-7b12-4fc5-90ed-320f29e89419").ExtractErr()
    81  	th.AssertNoErr(t, err)
    82  }