You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
resource_test.go:109: Error running post-test destroy, there may be dangling resources: Check 1/1 error: httpclient_resource.test-resource: Attribute 'variables.name' found when not expected
Steps to Reproduce
run TF_ACC=1 go test -v ./...
References
None
The text was updated successfully, but these errors were encountered:
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:
terraform-plugin-testing version
Relevant provider source code
provider code
Terraform Configuration Files
In the test code, linked above.
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
The text was updated successfully, but these errors were encountered: