|
1 | 1 | package tencentcloud |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "regexp" |
5 | 6 | "testing" |
6 | 7 |
|
@@ -35,6 +36,8 @@ func TestAccDataSourceTencentCloudScfFunctions_basic(t *testing.T) { |
35 | 36 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.l5_enable"), |
36 | 37 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.trigger_info.#"), |
37 | 38 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.async_run_enable"), |
| 39 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.dns_cache", "false"), |
| 40 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.intranet_config.0.ip_fixed", "DISABLE"), |
38 | 41 | ), |
39 | 42 | }, |
40 | 43 | }, |
@@ -68,6 +71,8 @@ func TestAccDataSourceTencentCloudScfFunctions_namespace(t *testing.T) { |
68 | 71 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.eips.#"), |
69 | 72 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.l5_enable"), |
70 | 73 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.trigger_info.#"), |
| 74 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.dns_cache", "false"), |
| 75 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.intranet_config.0.ip_fixed", "DISABLE"), |
71 | 76 | ), |
72 | 77 | }, |
73 | 78 | }, |
@@ -102,6 +107,8 @@ func TestAccDataSourceTencentCloudScfFunctions_Desc(t *testing.T) { |
102 | 107 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.eips.#"), |
103 | 108 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.l5_enable"), |
104 | 109 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.trigger_info.#"), |
| 110 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.dns_cache", "false"), |
| 111 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.intranet_config.0.ip_fixed", "DISABLE"), |
105 | 112 | ), |
106 | 113 | }, |
107 | 114 | }, |
@@ -136,6 +143,44 @@ func TestAccDataSourceTencentCloudScfFunctions_tag(t *testing.T) { |
136 | 143 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.l5_enable"), |
137 | 144 | resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.trigger_info.#"), |
138 | 145 | resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.tags.test", "test"), |
| 146 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.dns_cache", "false"), |
| 147 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.intranet_config.0.ip_fixed", "DISABLE"), |
| 148 | + ), |
| 149 | + }, |
| 150 | + }, |
| 151 | + }) |
| 152 | +} |
| 153 | + |
| 154 | +func TestAccDataSourceTencentCloudScfFunctions_IntranetConfig(t *testing.T) { |
| 155 | + t.Parallel() |
| 156 | + resource.Test(t, resource.TestCase{ |
| 157 | + PreCheck: func() { testAccPreCheck(t) }, |
| 158 | + Providers: testAccProviders, |
| 159 | + Steps: []resource.TestStep{ |
| 160 | + { |
| 161 | + Config: scfFunctionCodeEmbed("first.zip", TestAccDataSourceTencentCloudScfFunctionsIntranetConfig), |
| 162 | + Check: resource.ComposeTestCheckFunc( |
| 163 | + testAccCheckTencentCloudDataSourceID("data.tencentcloud_scf_functions.foo"), |
| 164 | + resource.TestMatchResourceAttr("data.tencentcloud_scf_functions.foo", "functions.#", regexp.MustCompile(`^[1-9]\d*$`)), |
| 165 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.name"), |
| 166 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.handler"), |
| 167 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.mem_size"), |
| 168 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.timeout"), |
| 169 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.runtime"), |
| 170 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.namespace"), |
| 171 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.create_time"), |
| 172 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.modify_time"), |
| 173 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.code_size"), |
| 174 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.err_no"), |
| 175 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.install_dependency"), |
| 176 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.status"), |
| 177 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.eip_fixed"), |
| 178 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.eips.#"), |
| 179 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.l5_enable"), |
| 180 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.trigger_info.#"), |
| 181 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.dns_cache", "true"), |
| 182 | + resource.TestCheckResourceAttr("data.tencentcloud_scf_functions.foo", "functions.0.intranet_config.0.ip_fixed", "ENABLE"), |
| 183 | + resource.TestCheckResourceAttrSet("data.tencentcloud_scf_functions.foo", "functions.0.intranet_config.0.ip_address.#"), |
139 | 184 | ), |
140 | 185 | }, |
141 | 186 | }, |
@@ -207,3 +252,25 @@ data "tencentcloud_scf_functions" "foo" { |
207 | 252 | tags = tencentcloud_scf_function.foo.tags |
208 | 253 | } |
209 | 254 | ` |
| 255 | + |
| 256 | +var TestAccDataSourceTencentCloudScfFunctionsIntranetConfig = fmt.Sprintf(defaultVpcVariable+` |
| 257 | +resource "tencentcloud_scf_function" "foo" { |
| 258 | + name = "%s" |
| 259 | + handler = "first.do_it_first" |
| 260 | + runtime = "Python3.6" |
| 261 | + enable_public_net = true |
| 262 | + dns_cache = true |
| 263 | +
|
| 264 | + intranet_config { |
| 265 | + ip_fixed = "ENABLE" |
| 266 | + } |
| 267 | + vpc_id = var.vpc_id |
| 268 | + subnet_id = var.subnet_id |
| 269 | +
|
| 270 | + zip_file = "%s" |
| 271 | +} |
| 272 | +
|
| 273 | +data "tencentcloud_scf_functions" "foo" { |
| 274 | + name = tencentcloud_scf_function.foo.name |
| 275 | +} |
| 276 | +`, "%s", "%s") |
0 commit comments