Closed kvaidas closed 2 months ago
Hey @kvaidas 👋🏻, thanks for providing that example and sorry you're running into trouble here.
The CheckDestroy
function is useful for a provider to test that the resource doesn't exist in the remote system, not Terraform state. Since the state value for a resource after destroy will always be null (you don't really need to test this, since Terraform core handles this logic), CheckDestroy
passes the last state value prior to the destroy command being run. So your test is actually running on an old version of state, checking that the attribute variables.name
was null before the resource was actually destroyed.
Usually this old state in CheckDestroy
is used to extract an ID and check the remote system to make sure the resource was fully deleted. Here's an example with the AWS tag resource:
With that being said, I believe CheckDestroy
is operating as intended, so I'm going to close this issue. Let me know if I missed anything!
terraform-plugin-testing version
Relevant provider source code
provider code
Terraform Configuration Files
Expected Behavior
Test should succeed since the delete resource API call is being sent. Running this provider using Terraform (as a user) works as expected, resource in the state file also is deleted.
Actual Behavior
Fails with the following error:
Steps to Reproduce
run
TF_ACC=1 go test -v ./...
References
None