Skip to content

Commit

Permalink
Merge pull request #390 from envato/page_rules_fix_2
Browse files Browse the repository at this point in the history
Bugfix: browser_cache_ttl is incorrectly sent as a string when unchanged
  • Loading branch information
jacobbednarz authored Jun 25, 2019
2 parents 2327af1 + 53253f0 commit eda81d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloudflare/resource_cloudflare_page_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ func transformToCloudflarePageRuleAction(id string, value interface{}, d *schema
changed := d.HasChange(fmt.Sprintf("actions.0.%s", id))

if strValue, ok := value.(string); ok {
if id == "browser_cache_ttl" && changed {
if id == "browser_cache_ttl" {
intValue, err := strconv.Atoi(strValue)
if err == nil {
pageRuleAction.Value = intValue
Expand Down
18 changes: 18 additions & 0 deletions cloudflare/resource_cloudflare_page_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,24 @@ func TestAccCloudflarePageRule_CreatesBrowserCacheTTLThatRespectsExistingHeaders
})
}

func TestAccCloudflarePageRule_UpdatesBrowserCacheTTLToSameValue(t *testing.T) {
var pageRule cloudflare.PageRule
testAccRunResourceTestSteps(t, []resource.TestStep{
{
Config: buildPageRuleConfig("test", "browser_cache_ttl = 1"),
},
{
Config: buildPageRuleConfig("test", `browser_cache_ttl = 1
browser_check = "on"`),
Check: resource.ComposeTestCheckFunc(
testAccCheckCloudflarePageRuleExists("cloudflare_page_rule.test", &pageRule),
testAccCheckCloudflarePageRuleHasAction(&pageRule, "browser_cache_ttl", float64(1)),
resource.TestCheckResourceAttr("cloudflare_page_rule.test", "actions.0.browser_cache_ttl", "1"),
),
},
})
}

func TestAccCloudflarePageRule_UpdatesBrowserCacheTTLThatRespectsExistingHeaders(t *testing.T) {
var pageRule cloudflare.PageRule
testAccRunResourceTestSteps(t, []resource.TestStep{
Expand Down

0 comments on commit eda81d0

Please sign in to comment.