Skip to content

Commit 11997dd

Browse files
author
Andrew Jeffery
committed
Add acceptance tests for rulesets lists
This tests CRUD operations for the various types of lists, as well as testing the data source and import functionality.
1 parent 6f3f1de commit 11997dd

15 files changed

+265
-134
lines changed

internal/services/list/data_source.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (d *ListDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
6767
env := ListResultDataSourceEnvelope{*data}
6868
_, err := d.client.Rules.Lists.Get(
6969
ctx,
70-
data.ID.ValueString(),
70+
data.ListID.ValueString(),
7171
params,
7272
option.WithResponseBodyInto(&res),
7373
option.WithMiddleware(logging.Middleware(ctx)),

internal/services/list/data_source_model.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ type ListResultDataSourceEnvelope struct {
1616
}
1717

1818
type ListDataSourceModel struct {
19-
ID types.String `tfsdk:"id" path:"id,required"`
2019
AccountID types.String `tfsdk:"account_id" path:"account_id,required"`
20+
ListID types.String `tfsdk:"list_id" path:"list_id,required"`
21+
ID types.String `tfsdk:"id" path:"list_id,computed"`
2122
CreatedOn types.String `tfsdk:"created_on" json:"created_on,computed"`
2223
Description types.String `tfsdk:"description" json:"description,computed"`
2324
Kind types.String `tfsdk:"kind" json:"kind,computed"`

internal/services/list/data_source_schema.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ var _ datasource.DataSourceWithConfigValidators = (*ListDataSource)(nil)
1616
func DataSourceSchema(ctx context.Context) schema.Schema {
1717
return schema.Schema{
1818
Attributes: map[string]schema.Attribute{
19-
"id": schema.StringAttribute{
20-
Description: "The unique ID of the list.",
21-
Required: true,
22-
},
2319
"account_id": schema.StringAttribute{
2420
Description: "The Account ID for this resource.",
2521
Required: true,
2622
},
23+
"list_id": schema.StringAttribute{
24+
Description: "The unique ID of the list.",
25+
Required: true,
26+
},
27+
"id": schema.StringAttribute{
28+
Description: "The unique ID of the list.",
29+
Computed: true,
30+
},
2731
"created_on": schema.StringAttribute{
2832
Description: "The RFC 3339 timestamp of when the list was created.",
2933
Computed: true,

internal/services/list/resource_test.go

Lines changed: 237 additions & 53 deletions
Large diffs are not rendered by default.
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
2-
resource "cloudflare_list" "%[1]s" {
3-
account_id = "%[4]s"
4-
name = "%[2]s"
5-
description = "%[3]s"
6-
kind = "%[5]s"
7-
}
1+
resource "cloudflare_list" "%[1]s" {
2+
account_id = "%[4]s"
3+
name = "%[2]s"
4+
description = "%[3]s"
5+
kind = "%[5]s"
6+
}

internal/services/list/testdata/listasnupdate.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

internal/services/list/testdata/listbasicip.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "cloudflare_list" "%[1]s" {
2+
account_id = "%[2]s"
3+
name = "%[3]s"
4+
description = "%[4]s"
5+
kind = "%[5]s"
6+
}
7+
8+
data "cloudflare_list" "%[1]s" {
9+
account_id = "%[2]s"
10+
list_id = cloudflare_list.%[1]s.id
11+
}

internal/services/list/testdata/listhostnameupdate.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

internal/services/list/testdata/listiplistordered.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)