Skip to content

Commit

Permalink
fix nil check for query_string
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbednarz committed Mar 3, 2021
1 parent 0cadda6 commit a8a428a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cloudflare/resource_cloudflare_page_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ func transformToCloudflarePageRuleAction(id string, value interface{}, d *schema
// Ensure that if no `include`, `exclude` or `ignore` attributes are
// set, we default to including all query string parameters in the
// cache key.
if !ignore.(bool) {
if ignore == nil || !ignore.(bool) {
if (!ok1 || len(exclude.([]interface{})) == 0) && (!ok2 || len(include.([]interface{})) == 0) {
sectionOutput["include"] = "*"
}
Expand Down
4 changes: 2 additions & 2 deletions cloudflare/resource_cloudflare_page_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ func TestCacheKeyFieldsNilValue(t *testing.T) {
t.Fatalf("Unexpected error transforming page rule action: %s", err)
}

if !reflect.DeepEqual(pageRuleAction.Value.(map[string]interface{})["query_string"], map[string]interface{}{"include": []interface{}{"*"}}) {
t.Fatalf("Unexpected transformToCloudflarePageRuleAction result, expected %#v, got %#v", map[string]interface{}{"include": []interface{}{"*"}}, pageRuleAction.Value.(map[string]interface{})["query_string"])
if !reflect.DeepEqual(pageRuleAction.Value.(map[string]interface{})["query_string"], map[string]interface{}{"include": "*"}) {
t.Fatalf("Unexpected transformToCloudflarePageRuleAction result, expected %#v, got %#v", map[string]interface{}{"include": "*"}, pageRuleAction.Value.(map[string]interface{})["query_string"])
}
}

Expand Down

0 comments on commit a8a428a

Please sign in to comment.