github.com/sacloud/libsacloud/v2@v2.32.3/helper/service/enhanceddb/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 enhanceddb 16 17 import ( 18 "testing" 19 20 "github.com/sacloud/libsacloud/v2/sacloud" 21 "github.com/sacloud/libsacloud/v2/sacloud/testutil" 22 "github.com/sacloud/libsacloud/v2/sacloud/types" 23 "github.com/stretchr/testify/require" 24 ) 25 26 func TestEnhancedDBService_convertApplyRequest(t *testing.T) { 27 caller := testutil.SingletonAPICaller() 28 name := testutil.ResourceName("container-registry-service") 29 dbName := testutil.RandomName(10, testutil.CharSetAlpha) 30 password := testutil.RandomName(16, testutil.CharSetAlpha) 31 32 cases := []struct { 33 in *ApplyRequest 34 expect *Builder 35 }{ 36 { 37 in: &ApplyRequest{ 38 Name: name, 39 Description: "desc", 40 Tags: types.Tags{"tag1", "tag2"}, 41 DatabaseName: dbName, 42 Password: password, 43 SettingsHash: "aaaaaaaa", 44 }, 45 expect: &Builder{ 46 ID: 0, 47 Name: name, 48 Description: "desc", 49 Tags: types.Tags{"tag1", "tag2"}, 50 IconID: 0, 51 DatabaseName: dbName, 52 Password: password, 53 SettingsHash: "aaaaaaaa", 54 Client: sacloud.NewEnhancedDBOp(caller), 55 }, 56 }, 57 } 58 59 for _, tc := range cases { 60 builder, err := tc.in.Builder(caller) 61 require.NoError(t, err) 62 require.EqualValues(t, tc.expect, builder) 63 } 64 }