Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: browser_cache_ttl is incorrectly sent as a string when unchanged #390

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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