github.com/sacloud/libsacloud/v2@v2.32.3/helper/service/enhanceddb/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 enhanceddb
    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 TestEnhancedDBService_convertCreateRequest(t *testing.T) {
    26  	name := testutil.ResourceName("container-registry-service")
    27  	dbName := testutil.RandomName(10, testutil.CharSetAlpha)
    28  	password := testutil.RandomName(16, testutil.CharSetAlpha)
    29  
    30  	cases := []struct {
    31  		in     *CreateRequest
    32  		expect *ApplyRequest
    33  	}{
    34  		{
    35  			in: &CreateRequest{
    36  				Name:         name,
    37  				Description:  "desc",
    38  				Tags:         types.Tags{"tag1", "tag2"},
    39  				IconID:       1,
    40  				DatabaseName: dbName,
    41  				Password:     password,
    42  			},
    43  			expect: &ApplyRequest{
    44  				ID:           0,
    45  				Name:         name,
    46  				Description:  "desc",
    47  				Tags:         types.Tags{"tag1", "tag2"},
    48  				IconID:       1,
    49  				DatabaseName: dbName,
    50  				Password:     password,
    51  				SettingsHash: "",
    52  			},
    53  		},
    54  	}
    55  
    56  	for _, tc := range cases {
    57  		require.EqualValues(t, tc.expect, tc.in.ApplyRequest())
    58  	}
    59  }