Skip to content
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

Merged
merged 4 commits into from May 31, 2022

Commits on May 26, 2022

  1. helper/resource: Support TestStep provider handling

    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.
    bflad committed May 26, 2022
    Copy the full SHA
    b3458d4 View commit details
    Browse the repository at this point in the history
  2. Update CHANGELOG for #972

    bflad committed May 26, 2022
    Copy the full SHA
    83ac96b View commit details
    Browse the repository at this point in the history
  3. helper/resource: Fixes for golangci-lint issues

    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 {
    	   ^
    ```
    bflad committed May 26, 2022
    Copy the full SHA
    a8e255a View commit details
    Browse the repository at this point in the history

Commits on May 27, 2022

  1. helper/resource: Ensure TestStep.Taint state show only happens when s…

    …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
    ```
    bflad committed May 27, 2022
    Copy the full SHA
    8a0031d View commit details
    Browse the repository at this point in the history