Skip to content

Commit bd3c296

Browse files
committed
fix: custom page tests
1 parent af9f117 commit bd3c296

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

internal/services/custom_pages/model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type CustomPagesModel struct {
1919
AccountID types.String `tfsdk:"account_id" path:"account_id,optional"`
2020
ZoneID types.String `tfsdk:"zone_id" path:"zone_id,optional"`
2121
State types.String `tfsdk:"state" json:"state,required"`
22-
URL types.String `tfsdk:"url" json:"url,required"`
22+
URL types.String `tfsdk:"url" json:"url,computed_optional"`
2323
CreatedOn timetypes.RFC3339 `tfsdk:"created_on" json:"created_on,computed" format:"date-time"`
2424
Description types.String `tfsdk:"description" json:"description,computed"`
2525
ModifiedOn timetypes.RFC3339 `tfsdk:"modified_on" json:"modified_on,computed" format:"date-time"`

internal/services/custom_pages/resource.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ func (r *CustomPagesResource) Create(ctx context.Context, req resource.CreateReq
9999
}
100100
data = &env.Result
101101
data.ID = data.Identifier
102+
if env.Result.URL.IsNull() || env.Result.URL.ValueString() == "" || env.Result.URL.ValueString() == "null" {
103+
data.URL = types.StringValue("")
104+
}
102105

103106
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
104107
}
@@ -155,6 +158,9 @@ func (r *CustomPagesResource) Update(ctx context.Context, req resource.UpdateReq
155158
}
156159
data = &env.Result
157160
data.ID = data.Identifier
161+
if env.Result.URL.IsNull() || env.Result.URL.ValueString() == "" || env.Result.URL.ValueString() == "null" {
162+
data.URL = types.StringValue("")
163+
}
158164

159165
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
160166
}
@@ -202,6 +208,9 @@ func (r *CustomPagesResource) Read(ctx context.Context, req resource.ReadRequest
202208
}
203209
data = &env.Result
204210
data.ID = data.Identifier
211+
if env.Result.URL.IsNull() || env.Result.URL.ValueString() == "" || env.Result.URL.ValueString() == "null" {
212+
data.URL = types.StringValue("")
213+
}
205214

206215
resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
207216
}

internal/services/custom_pages/resource_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ func TestAccCloudflareCustomPages_ZoneRatelimitBlock(t *testing.T) {
399399
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("url"), knownvalue.StringExact("")),
400400
statecheck.ExpectKnownValue(resourceName, tfjsonpath.New("account_id"), knownvalue.Null()),
401401
},
402+
ConfigPlanChecks: resource.ConfigPlanChecks{
403+
PostApplyPostRefresh: acctest.LogResourceDrift,
404+
},
402405
},
403406
{
404407
Config: testAccCustomPagesZoneConfig(rnd, zoneID, "ratelimit_block", "customized", "https://custom-pages-waf-challenge.terraform-provider-acceptance-testing.workers.dev/"),

0 commit comments

Comments
 (0)