hashicorp / hashicorp/terraform-plugin-testing

SkipPostTestDestroy option in TestCase

Open
#609 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
68
Forks
22
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### 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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.