Skip to content

SkipPostTestDestroy option in TestCase #609

@saisrikark

Description

@saisrikark

SDK version

github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1

Use-cases

I want to run testcases on resources that are already created.
An example is import a resource that always exists and check whether the existing plan has a diff compared to the imported resource.

Attempted Solutions

I have tried to run tests but there is no option to prevent a destroy of the resource after all steps are completed

Proposal

Add an option SkipPostTestDestroy that prevents destory of resources in the state after all steps are complete
By default this option is false to ensure backward compatibility
To be added here https://github.com/hashicorp/terraform-plugin-sdk/blob/v2.38.1/helper/resource/testing_new.go#L78

I assume SkipPostTestDestroy is not present to avoid keeping lingering resources
In certain cases, we will need this option

References

https://github.com/hashicorp/terraform-plugin-sdk/blob/v2.38.1/helper/resource/testing.go#L308
https://github.com/hashicorp/terraform-plugin-sdk/blob/v2.38.1/helper/resource/testing_new.go#L78

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions