@@ -6,27 +6,50 @@ import (
66 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
77)
88
9- func TestAccDataSourceTencentCloudCcnV3BandwidthLimitsBasic (t * testing.T ) {
9+ func TestAccDataSourceTencentCloudCcnV3BandwidthLimitsOuter (t * testing.T ) {
1010 keyName := "data.tencentcloud_ccn_bandwidth_limits.limit"
1111 resource .Test (t , resource.TestCase {
1212 PreCheck : func () { testAccPreCheck (t ) },
1313 Providers : testAccProviders ,
1414 Steps : []resource.TestStep {
1515 {
16- Config : TestAccDataSourceTencentCloudCcnBandwidthLimits ,
16+ Config : TestAccDataSourceTencentCloudCcnOuterBandwidthLimits ,
1717
1818 Check : resource .ComposeTestCheckFunc (
1919 testAccCheckTencentCloudDataSourceID (keyName ),
2020 resource .TestCheckResourceAttrSet (keyName , "ccn_id" ),
21- resource .TestCheckResourceAttrSet (keyName , "limits.#" ),
21+ resource .TestCheckResourceAttr (keyName , "limits.#" , "1" ),
22+ resource .TestCheckResourceAttr (keyName , "limits.0.region" , "ap-shanghai" ),
23+ resource .TestCheckResourceAttr (keyName , "limits.0.bandwidth_limit" , "500" ),
2224 ),
2325 },
2426 },
2527 })
2628}
2729
28- const TestAccDataSourceTencentCloudCcnBandwidthLimits = `
30+ func TestAccDataSourceTencentCloudCcnV3BandwidthLimitsInter (t * testing.T ) {
31+ keyName := "data.tencentcloud_ccn_bandwidth_limits.limit"
32+ resource .Test (t , resource.TestCase {
33+ PreCheck : func () { testAccPreCheck (t ) },
34+ Providers : testAccProviders ,
35+ Steps : []resource.TestStep {
36+ {
37+ Config : TestAccDataSourceTencentCloudCcnInterBandwidthLimits ,
2938
39+ Check : resource .ComposeTestCheckFunc (
40+ testAccCheckTencentCloudDataSourceID (keyName ),
41+ resource .TestCheckResourceAttrSet (keyName , "ccn_id" ),
42+ resource .TestCheckResourceAttr (keyName , "limits.#" , "1" ),
43+ resource .TestCheckResourceAttr (keyName , "limits.0.region" , "ap-shanghai" ),
44+ resource .TestCheckResourceAttr (keyName , "limits.0.dst_region" , "ap-beijing" ),
45+ resource .TestCheckResourceAttr (keyName , "limits.0.bandwidth_limit" , "500" ),
46+ ),
47+ },
48+ },
49+ })
50+ }
51+
52+ const TestAccDataSourceTencentCloudCcnOuterBandwidthLimits = `
3053variable "other_region1" {
3154 default = "ap-shanghai"
3255}
@@ -37,13 +60,41 @@ resource tencentcloud_ccn main {
3760 qos = "AG"
3861}
3962
63+ resource tencentcloud_ccn_bandwidth_limit limit1 {
64+ ccn_id = tencentcloud_ccn.main.id
65+ region = var.other_region1
66+ bandwidth_limit = 500
67+ }
68+
4069data tencentcloud_ccn_bandwidth_limits limit {
41- ccn_id = tencentcloud_ccn.main.id
70+ ccn_id = tencentcloud_ccn_bandwidth_limit.limit1.ccn_id
71+ }
72+ `
73+
74+ const TestAccDataSourceTencentCloudCcnInterBandwidthLimits = `
75+ variable "other_region1" {
76+ default = "ap-shanghai"
77+ }
78+
79+ variable "other_region2" {
80+ default = "ap-beijing"
81+ }
82+
83+ resource tencentcloud_ccn main {
84+ name = "ci-temp-test-ccn"
85+ description = "ci-temp-test-ccn-des"
86+ qos = "AG"
87+ bandwidth_limit_type = "INTER_REGION_LIMIT"
4288}
4389
4490resource tencentcloud_ccn_bandwidth_limit limit1 {
4591 ccn_id = tencentcloud_ccn.main.id
4692 region = var.other_region1
93+ dst_region = var.other_region2
4794 bandwidth_limit = 500
4895}
96+
97+ data tencentcloud_ccn_bandwidth_limits limit {
98+ ccn_id = tencentcloud_ccn_bandwidth_limit.limit1.ccn_id
99+ }
49100`
0 commit comments