From ad5cb737df357c72649b3e46853094b5a3a74b6a Mon Sep 17 00:00:00 2001 From: Zaidoon Abd Al Hadi Date: Thu, 2 Jan 2025 21:39:44 -0500 Subject: [PATCH] add more tests --- ..._cloudflare_zone_settings_override_test.go | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/internal/sdkv2provider/resource_cloudflare_zone_settings_override_test.go b/internal/sdkv2provider/resource_cloudflare_zone_settings_override_test.go index ffe526b1b3..fcae3209f1 100644 --- a/internal/sdkv2provider/resource_cloudflare_zone_settings_override_test.go +++ b/internal/sdkv2provider/resource_cloudflare_zone_settings_override_test.go @@ -260,23 +260,62 @@ func TestAccCloudflareZoneSettingsOverride_Aegis(t *testing.T) { ProviderFactories: providerFactories, Steps: []resource.TestStep{ { - Config: testAccCheckCloudflareZoneSettingsOverrideAegis(rnd, zoneID), + Config: testAccCheckCloudflareZoneSettingsOverrideAegisEnable(rnd, zoneID), Check: resource.ComposeTestCheckFunc( - testAccCheckCloudflareZoneSettings(name), - resource.TestCheckResourceAttr(name, "settings.0.aegis.0.pool_id", "example-pool"), + resource.TestCheckResourceAttr(name, "settings.0.aegis.0.pool_id", "cache-team-trakal-pool"), + resource.TestCheckResourceAttr(name, "settings.0.aegis.0.enabled", "true"), + ), + }, + { + Config: testAccCheckCloudflareZoneSettingsOverrideAegisDisable(rnd, zoneID), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "settings.0.aegis.0.pool_id", ""), + resource.TestCheckResourceAttr(name, "settings.0.aegis.0.enabled", "false"), + ), + }, + { + Config: testAccCheckCloudflareZoneSettingsOverrideAegisEnableNoExplicitEnabled(rnd, zoneID), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(name, "settings.0.aegis.0.pool_id", "cache-team-trakal-pool"), + resource.TestCheckResourceAttr(name, "settings.0.aegis.0.enabled", "true"), ), }, }, }) } -func testAccCheckCloudflareZoneSettingsOverrideAegis(rnd, zoneID string) string { +func testAccCheckCloudflareZoneSettingsOverrideAegisEnable(rnd, zoneID string) string { + return fmt.Sprintf(` +resource "cloudflare_zone_settings_override" "%[1]s" { + zone_id = "%[2]s" + settings { + aegis { + enabled = true + pool_id = "cache-team-trakal-pool" + } + } +}`, rnd, zoneID) +} + +func testAccCheckCloudflareZoneSettingsOverrideAegisEnableNoExplicitEnabled(rnd, zoneID string) string { + return fmt.Sprintf(` +resource "cloudflare_zone_settings_override" "%[1]s" { + zone_id = "%[2]s" + settings { + aegis { + pool_id = "cache-team-trakal-pool" + } + } +}`, rnd, zoneID) +} + +func testAccCheckCloudflareZoneSettingsOverrideAegisDisable(rnd, zoneID string) string { return fmt.Sprintf(` resource "cloudflare_zone_settings_override" "%[1]s" { zone_id = "%[2]s" settings { aegis { - pool_id = "example-pool" + enabled = false } } }`, rnd, zoneID)