@@ -11,11 +11,8 @@ import (
11
11
tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
12
12
svctcr "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/tcr"
13
13
14
- "github.com/stretchr/testify/assert"
15
14
tcr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tcr/v20190924"
16
15
17
- "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
18
-
19
16
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
20
17
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
21
18
)
@@ -241,7 +238,7 @@ func TestAccTencentCloudTcrInstanceResource_replication(t *testing.T) {
241
238
tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY )
242
239
},
243
240
Check : resource .ComposeAggregateTestCheckFunc (
244
- resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas " ),
241
+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas1 " ),
245
242
resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "replications.#" , "2" ),
246
243
),
247
244
},
@@ -258,108 +255,50 @@ func TestAccTencentCloudTcrInstanceResource_replication(t *testing.T) {
258
255
tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY )
259
256
},
260
257
Check : resource .ComposeAggregateTestCheckFunc (
261
- resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas " ),
258
+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas1 " ),
262
259
resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "replications.#" , "3" ),
263
260
),
264
261
},
265
262
},
266
263
})
267
264
}
268
-
269
- func TestAccTencentCloudTcrInstanceResource_replica_set (t * testing.T ) {
270
- inputs := []interface {}{
271
- map [string ]interface {}{
272
- "region_id" : 1 ,
273
- "sync_cos" : true ,
274
- },
275
- map [string ]interface {}{
276
- "region_id" : 2 ,
277
- },
278
- map [string ]interface {}{
279
- "region_id" : 3 ,
280
- "sync_cos" : false ,
281
- },
282
- }
283
-
284
- registries1 := []* tcr.ReplicationRegistry {
285
- {
286
- ReplicationRegistryId : helper .String ("a" ),
287
- RegistryId : helper .String ("x" ),
288
- ReplicationRegionId : helper .IntUint64 (1 ),
289
- },
290
- {
291
- ReplicationRegistryId : helper .String ("b" ),
292
- RegistryId : helper .String ("x" ),
293
- ReplicationRegionId : helper .IntUint64 (2 ),
294
- },
295
- {
296
- ReplicationRegistryId : helper .String ("c" ),
297
- RegistryId : helper .String ("x" ),
298
- ReplicationRegionId : helper .IntUint64 (3 ),
299
- },
300
- }
301
-
302
- result1 := svctcr .ResourceTencentCloudTcrFillReplicas (inputs , registries1 )
303
- expected1 := []interface {}{
304
- map [string ]interface {}{
305
- "id" : "a" ,
306
- "region_id" : 1 ,
307
- "sync_cos" : true ,
308
- },
309
- map [string ]interface {}{
310
- "id" : "b" ,
311
- "region_id" : 2 ,
312
- },
313
- map [string ]interface {}{
314
- "id" : "c" ,
315
- "region_id" : 3 ,
316
- "sync_cos" : false ,
317
- },
318
- }
319
- assert .Equalf (t , expected1 , result1 , "%s case 1 not equal, expected:\n %v\n got: \n %v" , t .Name (), expected1 , result1 )
320
-
321
- var registries2 []* tcr.ReplicationRegistry
322
- registries2Incr := []* tcr.ReplicationRegistry {
323
- {
324
- ReplicationRegistryId : helper .String ("d" ),
325
- RegistryId : helper .String ("x" ),
326
- ReplicationRegionId : helper .IntUint64 (4 ),
327
- },
328
- {
329
- ReplicationRegistryId : helper .String ("e" ),
330
- RegistryId : helper .String ("x" ),
331
- ReplicationRegionId : helper .IntUint64 (5 ),
332
- },
333
- }
334
- registries2 = append (registries2 , registries1 ... )
335
- registries2 = append (registries2 , registries2Incr ... )
336
- result2 := svctcr .ResourceTencentCloudTcrFillReplicas (inputs , registries2 )
337
- expected2 := []interface {}{
338
- map [string ]interface {}{
339
- "id" : "a" ,
340
- "region_id" : 1 ,
341
- "sync_cos" : true ,
342
- },
343
- map [string ]interface {}{
344
- "id" : "b" ,
345
- "region_id" : 2 ,
346
- },
347
- map [string ]interface {}{
348
- "id" : "c" ,
349
- "region_id" : 3 ,
350
- "sync_cos" : false ,
351
- },
352
- map [string ]interface {}{
353
- "id" : "d" ,
354
- "region_id" : 4 ,
355
- },
356
- map [string ]interface {}{
357
- "id" : "e" ,
358
- "region_id" : 5 ,
265
+ func TestAccTencentCloudTcrInstanceResource_replication_regionName (t * testing.T ) {
266
+ // t.Parallel()
267
+ resource .Test (t , resource.TestCase {
268
+ PreCheck : func () { tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY ) },
269
+ Providers : tcacctest .AccProviders ,
270
+ CheckDestroy : testAccCheckTCRInstanceDestroy ,
271
+ Steps : []resource.TestStep {
272
+ {
273
+ Config : testAccTCRInstance_replica_regionName ,
274
+ PreConfig : func () {
275
+ tcacctest .AccStepSetRegion (t , "ap-guangzhou" )
276
+ tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY )
277
+ },
278
+ Check : resource .ComposeAggregateTestCheckFunc (
279
+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance_regionName" , "name" , "exampleregionname" ),
280
+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance_regionName" , "replications.#" , "1" ),
281
+ ),
282
+ },
283
+ {
284
+ Config : testAccTCRInstance_replica_regionName_update ,
285
+ PreConfig : func () {
286
+ tcacctest .AccStepSetRegion (t , "ap-guangzhou" )
287
+ tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY )
288
+ },
289
+ Check : resource .ComposeAggregateTestCheckFunc (
290
+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance_regionName" , "name" , "exampleregionname" ),
291
+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance_regionName" , "replications.#" , "2" ),
292
+ ),
293
+ },
294
+ {
295
+ ResourceName : "tencentcloud_tcr_instance.mytcr_instance_regionName" ,
296
+ ImportState : true ,
297
+ ImportStateVerify : true ,
298
+ ImportStateVerifyIgnore : []string {"delete_bucket" , "replications" },
299
+ },
359
300
},
360
- }
361
-
362
- assert .Equalf (t , expected2 , result2 , "%s case 2 not equal, expected:\n %v\n got: \n %v" , t .Name (), expected2 , result2 )
301
+ })
363
302
}
364
303
365
304
func testAccCheckTCRInstanceDestroy (s * terraform.State ) error {
@@ -446,7 +385,7 @@ resource "tencentcloud_tcr_instance" "mytcr_instance_paypaid" {
446
385
447
386
const testAccTCRInstance_replica = `
448
387
resource "tencentcloud_tcr_instance" "mytcr_instance" {
449
- name = "tfreplicas "
388
+ name = "tfreplicas1 "
450
389
instance_type = "premium"
451
390
delete_bucket = true
452
391
@@ -460,7 +399,7 @@ resource "tencentcloud_tcr_instance" "mytcr_instance" {
460
399
461
400
const testAccTCRInstance_replica_update = `
462
401
resource "tencentcloud_tcr_instance" "mytcr_instance" {
463
- name = "tfreplicas "
402
+ name = "tfreplicas1 "
464
403
instance_type = "premium"
465
404
delete_bucket = true
466
405
@@ -471,11 +410,39 @@ resource "tencentcloud_tcr_instance" "mytcr_instance" {
471
410
region_id = 8 # ap-beijing
472
411
}
473
412
replications {
474
- region_id = 16 #ap-chengdu
413
+ region_id = 15 #ap-chengdu
475
414
syn_tag = true
476
415
}
477
416
}`
478
417
418
+ const testAccTCRInstance_replica_regionName = `
419
+ resource "tencentcloud_tcr_instance" "mytcr_instance_regionName" {
420
+ name = "exampleregionname"
421
+ instance_type = "premium"
422
+ delete_bucket = true
423
+
424
+ replications {
425
+ region_name = "ap-shanghai"
426
+ }
427
+ }
428
+ `
429
+
430
+ const testAccTCRInstance_replica_regionName_update = `
431
+ resource "tencentcloud_tcr_instance" "mytcr_instance_regionName" {
432
+ name = "exampleregionname"
433
+ instance_type = "premium"
434
+ delete_bucket = true
435
+
436
+ replications {
437
+ region_name = "ap-shanghai"
438
+ }
439
+
440
+ replications {
441
+ region_name = "ap-nanjing"
442
+ }
443
+ }
444
+ `
445
+
479
446
const testAccTCRInstance_basic_update_remark = `
480
447
resource "tencentcloud_tcr_instance" "mytcr_instance" {
481
448
name = "testacctcrinstance1"
0 commit comments