github.com/sacloud/libsacloud/v2@v2.32.3/helper/service/disk/create_test.go (about)

     1  // Copyright 2016-2022 The Libsacloud Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package disk
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/sacloud/libsacloud/v2/sacloud/ostype"
    21  	"github.com/sacloud/libsacloud/v2/sacloud/types"
    22  	"github.com/stretchr/testify/require"
    23  )
    24  
    25  func TestDiskService_convertCreateRequest(t *testing.T) {
    26  	cases := []struct {
    27  		in     *CreateRequest
    28  		expect *ApplyRequest
    29  	}{
    30  		{
    31  			in: &CreateRequest{
    32  				Zone:       "is1a",
    33  				Name:       "test",
    34  				DiskPlanID: types.DiskPlans.SSD,
    35  				Connection: types.DiskConnections.VirtIO,
    36  				SizeGB:     20,
    37  				OSType:     ostype.Ubuntu,
    38  				EditParameter: &EditParameter{
    39  					HostName: "hostname",
    40  					Password: "password",
    41  				},
    42  				NoWait: true,
    43  			},
    44  			expect: &ApplyRequest{
    45  				Zone:       "is1a",
    46  				Name:       "test",
    47  				DiskPlanID: types.DiskPlans.SSD,
    48  				Connection: types.DiskConnections.VirtIO,
    49  				SizeGB:     20,
    50  				OSType:     ostype.Ubuntu,
    51  				EditParameter: &EditParameter{
    52  					HostName: "hostname",
    53  					Password: "password",
    54  				},
    55  				NoWait: true,
    56  			},
    57  		},
    58  	}
    59  
    60  	for _, tc := range cases {
    61  		require.EqualValues(t, tc.expect, tc.in.ApplyRequest())
    62  	}
    63  }