Skip to content

Commit

Permalink
Fix acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tobio committed Jun 1, 2023
1 parent 1b7a830 commit de1c33d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
9 changes: 0 additions & 9 deletions ec/acc/datasource_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,17 @@ func checkDataSourceStack(resName string, checks ...resource.TestCheckFunc) reso

// Elasticsearch
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.denylist.#"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.docker_image"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.plugins.#"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.default_plugins.#"),

// Kibana
resource.TestCheckResourceAttrSet(resName, "kibana.0.denylist.#"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.docker_image"),

// APM
resource.TestCheckResourceAttrSet(resName, "apm.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "apm.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "apm.0.docker_image"),

// Enterprise Search
resource.TestCheckResourceAttrSet(resName, "enterprise_search.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "enterprise_search.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "enterprise_search.0.docker_image"),
}, checks...)...)
}
25 changes: 25 additions & 0 deletions ec/ecresource/trafficfilterresource/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ func trafficFilterRuleSchema() schema.Block {
"id": schema.StringAttribute{
Description: "Computed rule ID",
Computed: true,
PlanModifiers: []planmodifier.String{
StringIsUnknown(),
},
// NOTE: The ID will change on update, so we intentionally do not use plan modifier resource.UseStateForUnknown() here!
},
},
Expand Down Expand Up @@ -183,3 +186,25 @@ type trafficFilterRuleModelV0 struct {
AzureEndpointName types.String `tfsdk:"azure_endpoint_name"`
AzureEndpointGUID types.String `tfsdk:"azure_endpoint_guid"`
}

type stringIsUnknown struct{}

func StringIsUnknown() planmodifier.String {
return &stringIsUnknown{}
}

func (m *stringIsUnknown) Description(ctx context.Context) string {
return m.MarkdownDescription(ctx)
}

func (m *stringIsUnknown) MarkdownDescription(ctx context.Context) string {
return "Sets the plan to unknown"
}

func (m *stringIsUnknown) PlanModifyString(ctx context.Context, req planmodifier.StringRequest, resp *planmodifier.StringResponse) {
if !req.ConfigValue.IsNull() {
return
}

req.PlanValue = types.StringUnknown()
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ require (
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.18.1 // indirect
github.com/hashicorp/terraform-json v0.16.0 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.17.2 // indirect
github.com/hashicorp/terraform-registry-address v0.1.0 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand Down

0 comments on commit de1c33d

Please sign in to comment.