github.com/sacloud/libsacloud/v2@v2.32.3/helper/service/nfs/apply_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 nfs
    16  
    17  import (
    18  	"testing"
    19  
    20  	"github.com/sacloud/libsacloud/v2/sacloud/testutil"
    21  	"github.com/sacloud/libsacloud/v2/sacloud/types"
    22  	"github.com/stretchr/testify/require"
    23  )
    24  
    25  func TestNFSService_convertApplyRequest(t *testing.T) {
    26  	caller := testutil.SingletonAPICaller()
    27  	name := testutil.ResourceName("nfs-service")
    28  	zone := testutil.TestZone()
    29  
    30  	cases := []struct {
    31  		in     *ApplyRequest
    32  		expect *Builder
    33  	}{
    34  		{
    35  			in: &ApplyRequest{
    36  				ID:             101,
    37  				Zone:           zone,
    38  				Name:           name,
    39  				Description:    "desc",
    40  				Tags:           types.Tags{"tag1", "tag2"},
    41  				SwitchID:       102,
    42  				Plan:           types.NFSPlans.SSD,
    43  				Size:           100,
    44  				IPAddresses:    []string{"192.168.0.101"},
    45  				NetworkMaskLen: 24,
    46  				DefaultRoute:   "192.168.0.1",
    47  				NoWait:         true,
    48  			},
    49  			expect: &Builder{
    50  				ID:             101,
    51  				Zone:           zone,
    52  				Name:           name,
    53  				Description:    "desc",
    54  				Tags:           types.Tags{"tag1", "tag2"},
    55  				SwitchID:       102,
    56  				Plan:           types.NFSPlans.SSD,
    57  				Size:           100,
    58  				IPAddresses:    []string{"192.168.0.101"},
    59  				NetworkMaskLen: 24,
    60  				DefaultRoute:   "192.168.0.1",
    61  				NoWait:         true,
    62  				Caller:         caller,
    63  			},
    64  		},
    65  	}
    66  
    67  	for _, tc := range cases {
    68  		require.EqualValues(t, tc.expect, tc.in.Builder(caller))
    69  	}
    70  }