Skip to content

Commit

Permalink
Fix regression by allowing providers defined at TestCase level with…
Browse files Browse the repository at this point in the history
… providers defined within `TestStep.Config` (#177)

* Removing checking whether TestStep.Config contains provider block to reinstate prior behaviour (#176)

* Adding changelog (#176)
  • Loading branch information
bendbennett committed Aug 31, 2023
1 parent 5b9c7a4 commit 23929ab
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/BUG FIXES-20230831-171932.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: BUG FIXES
body: 'helper/resource: Fix regression by allowing providers to be defined both at
the `TestCase` level, and within `TestStep.Config`'
time: 2023-08-31T17:19:32.516184+01:00
custom:
Issue: "177"
1 change: 0 additions & 1 deletion helper/resource/teststep_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func (s TestStep) hasProviders(ctx context.Context, stepIndex int, testName stri
configRequest := teststep.PrepareConfigurationRequest{
Directory: s.ConfigDirectory,
File: s.ConfigFile,
Raw: s.Config,
TestStepConfigRequest: config.TestStepConfigRequest{
StepNumber: stepIndex + 1,
TestName: testName,
Expand Down
13 changes: 13 additions & 0 deletions helper/resource/teststep_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,19 @@ func TestTestStepValidate(t *testing.T) {
},
expectedError: fmt.Errorf("TestStep ImportState must be specified with ImportStateId, ImportStateIdFunc, or ResourceName"),
},
// This test has been added to verify that providers can be defined
// both within the TestStep.Config and at the TestCase level.
// The regression was reported in
// https://github.com/hashicorp/terraform-plugin-testing/issues/176
"config-providers-testcase-providers": {
testStep: TestStep{
Config: "provider abc {",
},
testStepConfig: "# not empty",
testStepValidateRequest: testStepValidateRequest{
TestCaseHasProviders: true,
},
},
"protov5providerfactories-testcase-providers": {
testStep: TestStep{
ProtoV5ProviderFactories: map[string]func() (tfprotov5.ProviderServer, error){
Expand Down

0 comments on commit 23929ab

Please sign in to comment.