@@ -11,11 +11,8 @@ import (
1111 tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
1212 svctcr "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/tcr"
1313
14- "github.com/stretchr/testify/assert"
1514 tcr "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tcr/v20190924"
1615
17- "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
18-
1916 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
2017 "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
2118)
@@ -241,7 +238,7 @@ func TestAccTencentCloudTcrInstanceResource_replication(t *testing.T) {
241238 tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY )
242239 },
243240 Check : resource .ComposeAggregateTestCheckFunc (
244- resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas " ),
241+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas1 " ),
245242 resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "replications.#" , "2" ),
246243 ),
247244 },
@@ -258,108 +255,50 @@ func TestAccTencentCloudTcrInstanceResource_replication(t *testing.T) {
258255 tcacctest .AccPreCheckCommon (t , tcacctest .ACCOUNT_TYPE_PREPAY )
259256 },
260257 Check : resource .ComposeAggregateTestCheckFunc (
261- resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas " ),
258+ resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "name" , "tfreplicas1 " ),
262259 resource .TestCheckResourceAttr ("tencentcloud_tcr_instance.mytcr_instance" , "replications.#" , "3" ),
263260 ),
264261 },
265262 },
266263 })
267264}
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+ },
359300 },
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+ })
363302}
364303
365304func testAccCheckTCRInstanceDestroy (s * terraform.State ) error {
@@ -446,7 +385,7 @@ resource "tencentcloud_tcr_instance" "mytcr_instance_paypaid" {
446385
447386const testAccTCRInstance_replica = `
448387resource "tencentcloud_tcr_instance" "mytcr_instance" {
449- name = "tfreplicas "
388+ name = "tfreplicas1 "
450389 instance_type = "premium"
451390 delete_bucket = true
452391
@@ -460,7 +399,7 @@ resource "tencentcloud_tcr_instance" "mytcr_instance" {
460399
461400const testAccTCRInstance_replica_update = `
462401resource "tencentcloud_tcr_instance" "mytcr_instance" {
463- name = "tfreplicas "
402+ name = "tfreplicas1 "
464403 instance_type = "premium"
465404 delete_bucket = true
466405
@@ -471,11 +410,39 @@ resource "tencentcloud_tcr_instance" "mytcr_instance" {
471410 region_id = 8 # ap-beijing
472411 }
473412 replications {
474- region_id = 16 #ap-chengdu
413+ region_id = 15 #ap-chengdu
475414 syn_tag = true
476415 }
477416}`
478417
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+
479446const testAccTCRInstance_basic_update_remark = `
480447resource "tencentcloud_tcr_instance" "mytcr_instance" {
481448 name = "testacctcrinstance1"
0 commit comments