From 69b2ccedfa24810a0a185aee80957750434de614 Mon Sep 17 00:00:00 2001 From: Sai Dadireddy Date: Tue, 24 Sep 2024 12:31:03 -0700 Subject: [PATCH] Update test cases --- .../data_source_test.go | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/internal/framework/service/infrastructure_access_target/data_source_test.go b/internal/framework/service/infrastructure_access_target/data_source_test.go index 4497c8cc8a2..fa1b4e38db8 100644 --- a/internal/framework/service/infrastructure_access_target/data_source_test.go +++ b/internal/framework/service/infrastructure_access_target/data_source_test.go @@ -22,14 +22,14 @@ func TestAccCloudflareInfraAccessTarget_DataSource(t *testing.T) { Config: testCloudflareInfrastructureTargetsMatchNoIpv6(rnd1), Check: resource.ComposeTestCheckFunc( // We should expect this data source to have 1 resource - resource.TestCheckResourceAttr("data.cloudflare_zero_trust_infrastructure_targets."+rnd1, "resources.#", "1"), + resource.TestCheckResourceAttr("data.cloudflare_infrastructure_access_targets."+rnd1, "resources.#", "1"), // Check that there is no ipv6 object in this resource - resource.TestCheckNoResourceAttr("data.cloudflare_zero_trust_infrastructure_targets."+rnd1, "ip.ipv6"), + resource.TestCheckNoResourceAttr("data.cloudflare_infrastructure_access_targets."+rnd1, "ip.ipv6"), // Check the existing attributes of this resource - resource.TestCheckTypeSetElemNestedAttrs("data.cloudflare_zero_trust_infrastructure_targets."+rnd1, "resources.*", map[string]string{ + resource.TestCheckTypeSetElemNestedAttrs("cloudflare_infrastructure_access_targets."+rnd1, "resources.*", map[string]string{ "hostname": rnd1, "ip.ipv4.ip_addr": "187.26.29.249", - "ip.ipv4.virtual_network_id": "c77b744e-acc8-428f-9257-6878c046ed55", + "ip.ipv4.virtual_network_id": "b9c90134-52de-4903-81e8-004a3a06b435", }), ), }, @@ -37,19 +37,19 @@ func TestAccCloudflareInfraAccessTarget_DataSource(t *testing.T) { Config: testCloudflareInfrastructureTargetsMatchAll(rnd1, rnd2), Check: resource.ComposeTestCheckFunc( // Expect this data source to have 2 resources - resource.TestCheckResourceAttr("data.cloudflare_zero_trust_infrastructure_targets.all", "resources.#", "2"), + resource.TestCheckResourceAttr("data.cloudflare_infrastructure_access_targets.all", "resources.#", "2"), // Check the attributes of the first resource - resource.TestCheckTypeSetElemNestedAttrs("data.cloudflare_zero_trust_infrastructure_targets.all", "resources.*", map[string]string{ + resource.TestCheckTypeSetElemNestedAttrs("data.cloudflare_infrastructure_access_targets.all", "resources.*", map[string]string{ "hostname": rnd1, - "ip.ipv4.ip_addr": "187.26.29.249", - "ip.ipv4.virtual_network_id": "c77b744e-acc8-428f-9257-6878c046ed55", + "ip.ipv4.ip_addr": "187.26.29.233", + "ip.ipv4.virtual_network_id": "b9c90134-52de-4903-81e8-004a3a06b435", }), // Check the attributes of the second resource - resource.TestCheckTypeSetElemNestedAttrs("data.cloudflare_zero_trust_infrastructure_targets.all", "resources.*", map[string]string{ + resource.TestCheckTypeSetElemNestedAttrs("data.cloudflare_infrastructure_access_targets.all", "resources.*", map[string]string{ "hostname": rnd2, "ip.ipv4.ip_addr": "250.26.29.250", "ip.ipv6.ip_addr": "64c0:64e8:f0b4:8dbf:7104:72b0:ec8f:f5e0", - "ip.ipv6.virtual_network_id": "01920a8c-dc14-7bb2-b67b-14c858494a54", + "ip.ipv6.virtual_network_id": "b9c90134-52de-4903-81e8-004a3a06b435", }), ), }, @@ -60,19 +60,20 @@ func TestAccCloudflareInfraAccessTarget_DataSource(t *testing.T) { func testCloudflareInfrastructureTargetsMatchNoIpv6(hostname string) string { accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID") return fmt.Sprintf(` -resource "cloudflare_zero_trust_infrastructure_target" "%[2]s" { +resource "cloudflare_infrastructure_access_target" "%[2]s" { account_id = "%[1]s" hostname = "%[2]s" ip = { ipv4 = { - ip_addr = "187.26.29.249", - virtual_network_id = "c77b744e-acc8-428f-9257-6878c046ed55" + ip_addr = "187.26.29.233", + virtual_network_id = "b9c90134-52de-4903-81e8-004a3a06b435" } } } -data "cloudflare_zero_trust_infrastructure_targets" "%[2]s" { - depends_on = [cloudflare_zero_trust_infrastructure_target.%[2]s] +data "cloudflare_infrastructure_access_targets" "%[2]s" { + depends_on = [cloudflare_infrastructure_access_target.%[2]s] + account_id = "%[1]s" } `, accountID, hostname) } @@ -80,37 +81,38 @@ data "cloudflare_zero_trust_infrastructure_targets" "%[2]s" { func testCloudflareInfrastructureTargetsMatchAll(hostname1 string, hostname2 string) string { accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID") return fmt.Sprintf(` -resource "cloudflare_zero_trust_infrastructure_target" "%[2]s" { +resource "cloudflare_infrastructure_access_target" "%[2]s" { account_id = "%[1]s" hostname = "%[2]s" ip = { ipv4 = { ip_addr = "187.26.29.249", - virtual_network_id = "c77b744e-acc8-428f-9257-6878c046ed55" + virtual_network_id = "b9c90134-52de-4903-81e8-004a3a06b435" } } } -resource "cloudflare_zero_trust_infrastructure_target" "%[3]s" { +resource "cloudflare_infrastructure_access_target" "%[3]s" { account_id = "%[1]s" hostname = "%[3]s" ip = { ipv4 = { ip_addr = "250.26.29.250", - virtual_network_id = "01920a8c-dc14-7bb2-b67b-14c858494a54" + virtual_network_id = "b9c90134-52de-4903-81e8-004a3a06b435" }, ipv6 = { ip_addr = "64c0:64e8:f0b4:8dbf:7104:72b0:ec8f:f5e0", - virtual_network_id = "01920a8c-dc14-7bb2-b67b-14c858494a54" + virtual_network_id = "b9c90134-52de-4903-81e8-004a3a06b435" } } } -data "cloudflare_zero_trust_infrastructure_targets" "all" { +data "cloudflare_infrastructure_access_targets" "all" { depends_on = [ - cloudflare_zero_trust_infrastructure_target.%[2]s, - cloudflare_zero_trust_infrastructure_target.%[3]s + cloudflare_infrastructure_access_target.%[2]s, + cloudflare_infrastructure_access_target.%[3]s ] + account_id = "%[1]s" } `, accountID, hostname1, hostname2) }