Skip to content

Commit

Permalink
Removing ConfigStateChecks type (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jan 23, 2024
1 parent 6d8f112 commit 04cf3c9
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 142 deletions.
8 changes: 2 additions & 6 deletions helper/resource/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,12 @@ type TestStep struct {
// [plancheck]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/plancheck
RefreshPlanChecks RefreshPlanChecks

// ConfigStateChecks allow assertions to be made against the state file at different points of a Config (apply) test using a state check.
// ConfigStateChecks allow assertions to be made against the state file during a Config (apply) test using a state check.
// Custom state checks can be created by implementing the [StateCheck] interface, or by using a StateCheck implementation from the provided [statecheck] package
//
// [StateCheck]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/statecheck#StateCheck
// [statecheck]: https://pkg.go.dev/github.com/hashicorp/terraform-plugin-testing/statecheck
ConfigStateChecks ConfigStateChecks
ConfigStateChecks []statecheck.StateCheck

// PlanOnly can be set to only run `plan` with this configuration, and not
// actually apply it. This is useful for ensuring config changes result in
Expand Down Expand Up @@ -803,10 +803,6 @@ type RefreshPlanChecks struct {
PostRefresh []plancheck.PlanCheck
}

// ConfigStateChecks runs all state checks in the slice. This occurs after the apply and refresh of a Config test are run.
// All errors by state checks in this slice are aggregated, reported, and will result in a test failure.
type ConfigStateChecks []statecheck.StateCheck

// ParallelTest performs an acceptance test on a resource, allowing concurrency
// with other ParallelTest. The number of concurrent tests is controlled by the
// "go test" command -parallel flag.
Expand Down
5 changes: 3 additions & 2 deletions helper/resource/testing_new_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/providerserver"
"github.com/hashicorp/terraform-plugin-testing/internal/testing/testsdk/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/statecheck"
"github.com/hashicorp/terraform-plugin-testing/tfversion"
)

Expand Down Expand Up @@ -764,7 +765,7 @@ func Test_ConfigStateChecks_Called(t *testing.T) {
Steps: []TestStep{
{
Config: `resource "test_resource" "test" {}`,
ConfigStateChecks: ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
spy1,
spy2,
},
Expand Down Expand Up @@ -831,7 +832,7 @@ func Test_ConfigStateChecks_Errors(t *testing.T) {
Steps: []TestStep{
{
Config: `resource "test_resource" "test" {}`,
ConfigStateChecks: ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
spy1,
spy2,
spy3,
Expand Down
3 changes: 2 additions & 1 deletion helper/resource/teststep_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/internal/teststep"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/statecheck"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -468,7 +469,7 @@ func TestTestStepValidate(t *testing.T) {
},
"configstatechecks-not-config-mode": {
testStep: TestStep{
ConfigStateChecks: ConfigStateChecks{
ConfigStateChecks: []statecheck.StateCheck{
&stateCheckSpy{},
},
RefreshState: true,
Expand Down
Loading

0 comments on commit 04cf3c9

Please sign in to comment.