Skip to content

Commit 5e9e992

Browse files
committed
fix: modify test
1 parent fc545cd commit 5e9e992

File tree

2 files changed

+47
-16
lines changed

2 files changed

+47
-16
lines changed

tencentcloud/services/cdb/resource_tc_mysql_instance_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,3 +655,40 @@ resource "tencentcloud_mysql_instance" "mysql8" {
655655
}
656656
}`, value)
657657
}
658+
659+
const testAccMysql = `
660+
resource "tencentcloud_mysql_instance" "mysql" {
661+
auto_renew_flag = 0
662+
availability_zone = "ap-guangzhou-6"
663+
charge_type = "POSTPAID"
664+
cpu = 4
665+
device_type = "UNIVERSAL"
666+
engine_version = "8.0"
667+
first_slave_zone = "ap-guangzhou-7"
668+
force_delete = false
669+
instance_name = "keep_preset_mysql"
670+
internet_service = 0
671+
mem_size = 8000
672+
root_password = "Iac@123456"
673+
prepaid_period = 1
674+
project_id = 0
675+
security_groups = [
676+
"sg-05f7wnhn",
677+
]
678+
slave_deploy_mode = 1
679+
slave_sync_mode = 0
680+
subnet_id = "subnet-j10lsueq"
681+
tags = {}
682+
volume_size = 100
683+
vpc_id = "vpc-m0d2dbnn"
684+
# wait_switch = 1
685+
686+
parameters = {
687+
character_set_server = "utf8"
688+
lower_case_table_names = "0"
689+
max_connections = "1000"
690+
max_user_connections = 2
691+
long_query_time = "0.200000"
692+
}
693+
}
694+
`

tencentcloud/services/cdb/resource_tc_mysql_privilege_test.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAccTencentCloudMysqlPrivilegeResource(t *testing.T) {
2828
CheckDestroy: testAccMysqlPrivilegeDestroy,
2929
Steps: []resource.TestStep{
3030
{
31-
Config: testAccMysqlPrivilege(),
31+
Config: testAccMysqlPrivilege,
3232
Check: resource.ComposeAggregateTestCheckFunc(
3333
testAccMysqlPrivilegeExists,
3434
resource.TestCheckResourceAttrSet(testAccTencentCloudMysqlPrivilegeName, "mysql_id"),
@@ -40,7 +40,7 @@ func TestAccTencentCloudMysqlPrivilegeResource(t *testing.T) {
4040
),
4141
},
4242
{
43-
Config: testAccMysqlPrivilegeUpdate(),
43+
Config: testAccMysqlPrivilegeUpdate,
4444
Check: resource.ComposeAggregateTestCheckFunc(
4545
testAccMysqlPrivilegeExists,
4646
resource.TestCheckResourceAttrSet(testAccTencentCloudMysqlPrivilegeName, "mysql_id"),
@@ -183,19 +183,17 @@ func testAccMysqlPrivilegeDestroy(s *terraform.State) error {
183183
return nil
184184
}
185185

186-
func testAccMysqlPrivilege() string {
187-
return fmt.Sprintf(`
188-
%s
186+
const testAccMysqlPrivilege = testAccMysql + `
189187
resource "tencentcloud_mysql_account" "mysql_account" {
190-
mysql_id = local.mysql_id
188+
mysql_id = tencentcloud_mysql_instance.mysql.id
191189
name = "test11priv"
192190
host = "119.168.110.%%"
193191
password = "test1234"
194192
description = "test from terraform"
195193
}
196194
197195
resource "tencentcloud_mysql_privilege" "privilege" {
198-
mysql_id = local.mysql_id
196+
mysql_id = tencentcloud_mysql_instance.mysql.id
199197
account_name = tencentcloud_mysql_account.mysql_account.name
200198
account_host = tencentcloud_mysql_account.mysql_account.host
201199
global = ["TRIGGER"]
@@ -221,22 +219,19 @@ resource "tencentcloud_mysql_privilege" "privilege" {
221219
table_name = "user"
222220
column_name = "user"
223221
}
224-
}`, tcacctest.CommonPresetMysql)
225-
}
222+
}`
226223

227-
func testAccMysqlPrivilegeUpdate() string {
228-
return fmt.Sprintf(`
229-
%s
224+
const testAccMysqlPrivilegeUpdate = testAccMysql + `
230225
resource "tencentcloud_mysql_account" "mysql_account" {
231-
mysql_id = local.mysql_id
226+
mysql_id = tencentcloud_mysql_instance.mysql.id
232227
name = "test11priv"
233228
host = "119.168.110.%%"
234229
password = "test1234"
235230
description = "test from terraform"
236231
}
237232
238233
resource "tencentcloud_mysql_privilege" "privilege" {
239-
mysql_id = local.mysql_id
234+
mysql_id = tencentcloud_mysql_instance.mysql.id
240235
account_name = tencentcloud_mysql_account.mysql_account.name
241236
account_host = tencentcloud_mysql_account.mysql_account.host
242237
global = ["TRIGGER","SELECT"]
@@ -250,5 +245,4 @@ resource "tencentcloud_mysql_privilege" "privilege" {
250245
database_name = "mysql"
251246
table_name = "db"
252247
}
253-
}`, tcacctest.CommonPresetMysql)
254-
}
248+
}`

0 commit comments

Comments
 (0)