From a38388afc327fb54a31c67dafc7dc63a18b1c5e1 Mon Sep 17 00:00:00 2001 From: Karl Cheng Date: Wed, 1 Mar 2023 12:08:40 +1100 Subject: [PATCH] Add acceptance test --- .../resource_cloudflare_notification_policy.go | 2 +- .../resource_cloudflare_notification_policy_test.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/sdkv2provider/resource_cloudflare_notification_policy.go b/internal/sdkv2provider/resource_cloudflare_notification_policy.go index fdc575d8e9c..d29b72c409a 100644 --- a/internal/sdkv2provider/resource_cloudflare_notification_policy.go +++ b/internal/sdkv2provider/resource_cloudflare_notification_policy.go @@ -215,9 +215,9 @@ func getNotificationMechanisms(s *schema.Set) []cloudflare.NotificationMechanism func setNotificationMechanisms(md []cloudflare.NotificationMechanismData) *schema.Set { mechanisms := make([]interface{}, 0) + data := make(map[string]interface{}) for _, m := range md { - data := make(map[string]interface{}) data["name"] = m.Name data["id"] = m.ID mechanisms = append(mechanisms, data) diff --git a/internal/sdkv2provider/resource_cloudflare_notification_policy_test.go b/internal/sdkv2provider/resource_cloudflare_notification_policy_test.go index 5603b12c559..b59a3836d98 100644 --- a/internal/sdkv2provider/resource_cloudflare_notification_policy_test.go +++ b/internal/sdkv2provider/resource_cloudflare_notification_policy_test.go @@ -39,7 +39,7 @@ func TestAccCloudflareNotificationPolicy_Basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enabled", "true"), resource.TestCheckResourceAttr(resourceName, "alert_type", "universal_ssl_event_type"), resource.TestCheckResourceAttr(resourceName, consts.AccountIDSchemaKey, accountID), - ), + resource.TestCheckResourceAttr(resourceName, "email_integration.#", "2"), }, { Config: testCheckCloudflareNotificationPolicyUpdated(rnd, updatedPolicyName, updatedPolicyDesc, accountID), @@ -48,7 +48,7 @@ func TestAccCloudflareNotificationPolicy_Basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "description", updatedPolicyDesc), resource.TestCheckResourceAttr(resourceName, "enabled", "true"), resource.TestCheckResourceAttr(resourceName, "alert_type", "universal_ssl_event_type"), - resource.TestCheckResourceAttr(resourceName, consts.AccountIDSchemaKey, accountID), + resource.TestCheckResourceAttr(resourceName, "email_integration.#", "2"), ), }, }, @@ -67,6 +67,10 @@ func testCheckCloudflareNotificationPolicy(name, accountID string) string { name = "" id = "test@example.com" } + email_integration { + name = "" + id = "test2@example.com" + } }`, name, accountID) } @@ -82,6 +86,10 @@ func testCheckCloudflareNotificationPolicyUpdated(resName, policyName, policyDes name = "" id = "test@example.com" } + email_integration { + name = "" + id = "test2@example.com" + } }`, resName, policyName, policyDesc, accountID) }