-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ca26a4
commit fe44307
Showing
1 changed file
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,27 @@ func testEmailRoutingRuleConfig(resourceID, zoneID string, enabled bool, priorit | |
`, resourceID, zoneID, enabled, priority) | ||
} | ||
|
||
func TestAccTestEmailRoutingRule(t *testing.T) { | ||
func testEmailRoutingRuleConfigDrop(resourceID, zoneID string, enabled bool, priority int) string { | ||
return fmt.Sprintf(` | ||
resource "cloudflare_email_routing_rule" "%[1]s" { | ||
zone_id = "%[2]s" | ||
enabled = "%[3]t" | ||
priority = "%[4]d" | ||
name = "%[1]s" | ||
matcher { | ||
field = "to" | ||
type = "literal" | ||
value = "[email protected]" | ||
} | ||
action { | ||
type = "drop" | ||
} | ||
} | ||
`, resourceID, zoneID, enabled, priority) | ||
} | ||
|
||
func TestAccCloudflareEmailRoutingRule_Basic(t *testing.T) { | ||
rnd := generateRandomResourceName() | ||
name := "cloudflare_email_routing_rule." + rnd | ||
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID") | ||
|
@@ -59,3 +79,31 @@ func TestAccTestEmailRoutingRule(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
func TestAccCloudflareEmailRoutingRule_Drop(t *testing.T) { | ||
rnd := generateRandomResourceName() | ||
name := "cloudflare_email_routing_rule." + rnd | ||
zoneID := os.Getenv("CLOUDFLARE_ZONE_ID") | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: providerFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testEmailRoutingRuleConfigDrop(rnd, zoneID, true, 10), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(name, "enabled", "true"), | ||
resource.TestCheckResourceAttr(name, consts.ZoneIDSchemaKey, zoneID), | ||
resource.TestCheckResourceAttr(name, "priority", "10"), | ||
resource.TestCheckResourceAttr(name, "name", rnd), | ||
|
||
resource.TestCheckResourceAttr(name, "matcher.0.type", "literal"), | ||
resource.TestCheckResourceAttr(name, "matcher.0.field", "to"), | ||
resource.TestCheckResourceAttr(name, "matcher.0.value", "[email protected]"), | ||
|
||
resource.TestCheckResourceAttr(name, "action.0.type", "drop"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |