-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
helper/resource: Support TestStep provider handling #972
Conversation
Reference: #253 Reference: #628 Reference: #779 Provider developers can now select whether to configure providers for acceptance testing at the `TestCase` or `TestStep` level. Only one level may be used in this current implementation, however it may be possible to allow merged `TestCase` and `TestStep` configuration with additional validation logic to ensure a single provider is not specified multiple times across the merge result of all fields. This change also introduces some upfront `TestCase` and `TestStep` configuration validation when calling any of the `Test` functions, failing the test early if a problem is detected. There are other validations that are possible, however these are considered out of scope.
Previously: ``` func testStepNewImportState(ctx context.Context, t testing.T, c TestCase, helper *plugintest.Helper, wd *plugintest.WorkingDir, step TestStep, cfg string, providers *providerFactories) error { ^ helper/resource/plugin.go:163:47: SA5011: possible nil pointer dereference (staticcheck) for providerName, factory := range factories.legacy { ^ helper/resource/plugin.go:118:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck) if factories == nil { ^ ```
89f3e1e
to
a8e255a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!
…et and before TestStep providers are changed Previously: ``` --- FAIL: TestTest_TestStep_ExternalProviders_To_ProviderFactories_StateUpgraders (2.50s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/teststep_providers_test.go:275: Step 2/2 error: exit status 1 Failed to marshal state to json: schema version 0 for null_resource.test in state does not match version 1 from the provider /Users/bflad/src/github.com/hashicorp/terraform-plugin-sdk/helper/resource/testing_new.go:73: Error retrieving state, there may be dangling resources: exit status 1 Failed to marshal state to json: schema version 0 for null_resource.test in state does not match version 1 from the provider ```
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Closes #253
Closes #628
Closes #779
Provider developers can now select whether to configure providers for acceptance testing at the
TestCase
orTestStep
level. Only one level may be used in this current implementation, however it may be possible to allow mergedTestCase
andTestStep
configuration with additional validation logic to ensure a single provider is not specified multiple times across the merge result of all fields.This change also introduces some upfront
TestCase
andTestStep
configuration validation when calling any of theTest
functions, failing the test early if a problem is detected. There are other validations that are possible, however these are considered out of scope.