@@ -28,7 +28,7 @@ func TestAccTencentCloudMysqlPrivilegeResource(t *testing.T) {
28
28
CheckDestroy : testAccMysqlPrivilegeDestroy ,
29
29
Steps : []resource.TestStep {
30
30
{
31
- Config : testAccMysqlPrivilege () ,
31
+ Config : testAccMysqlPrivilege ,
32
32
Check : resource .ComposeAggregateTestCheckFunc (
33
33
testAccMysqlPrivilegeExists ,
34
34
resource .TestCheckResourceAttrSet (testAccTencentCloudMysqlPrivilegeName , "mysql_id" ),
@@ -40,7 +40,7 @@ func TestAccTencentCloudMysqlPrivilegeResource(t *testing.T) {
40
40
),
41
41
},
42
42
{
43
- Config : testAccMysqlPrivilegeUpdate () ,
43
+ Config : testAccMysqlPrivilegeUpdate ,
44
44
Check : resource .ComposeAggregateTestCheckFunc (
45
45
testAccMysqlPrivilegeExists ,
46
46
resource .TestCheckResourceAttrSet (testAccTencentCloudMysqlPrivilegeName , "mysql_id" ),
@@ -183,19 +183,17 @@ func testAccMysqlPrivilegeDestroy(s *terraform.State) error {
183
183
return nil
184
184
}
185
185
186
- func testAccMysqlPrivilege () string {
187
- return fmt .Sprintf (`
188
- %s
186
+ const testAccMysqlPrivilege = testAccMysql + `
189
187
resource "tencentcloud_mysql_account" "mysql_account" {
190
- mysql_id = local.mysql_id
188
+ mysql_id = tencentcloud_mysql_instance.mysql.id
191
189
name = "test11priv"
192
190
host = "119.168.110.%%"
193
191
password = "test1234"
194
192
description = "test from terraform"
195
193
}
196
194
197
195
resource "tencentcloud_mysql_privilege" "privilege" {
198
- mysql_id = local.mysql_id
196
+ mysql_id = tencentcloud_mysql_instance.mysql.id
199
197
account_name = tencentcloud_mysql_account.mysql_account.name
200
198
account_host = tencentcloud_mysql_account.mysql_account.host
201
199
global = ["TRIGGER"]
@@ -221,22 +219,19 @@ resource "tencentcloud_mysql_privilege" "privilege" {
221
219
table_name = "user"
222
220
column_name = "user"
223
221
}
224
- }` , tcacctest .CommonPresetMysql )
225
- }
222
+ }`
226
223
227
- func testAccMysqlPrivilegeUpdate () string {
228
- return fmt .Sprintf (`
229
- %s
224
+ const testAccMysqlPrivilegeUpdate = testAccMysql + `
230
225
resource "tencentcloud_mysql_account" "mysql_account" {
231
- mysql_id = local.mysql_id
226
+ mysql_id = tencentcloud_mysql_instance.mysql.id
232
227
name = "test11priv"
233
228
host = "119.168.110.%%"
234
229
password = "test1234"
235
230
description = "test from terraform"
236
231
}
237
232
238
233
resource "tencentcloud_mysql_privilege" "privilege" {
239
- mysql_id = local.mysql_id
234
+ mysql_id = tencentcloud_mysql_instance.mysql.id
240
235
account_name = tencentcloud_mysql_account.mysql_account.name
241
236
account_host = tencentcloud_mysql_account.mysql_account.host
242
237
global = ["TRIGGER","SELECT"]
@@ -250,5 +245,4 @@ resource "tencentcloud_mysql_privilege" "privilege" {
250
245
database_name = "mysql"
251
246
table_name = "db"
252
247
}
253
- }` , tcacctest .CommonPresetMysql )
254
- }
248
+ }`
0 commit comments