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

Make testing of resource disappearance easier to test #9

Closed
radeksimko opened this issue Jun 11, 2019 · 2 comments
Closed

Make testing of resource disappearance easier to test #9

radeksimko opened this issue Jun 11, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@radeksimko
Copy link
Member

Testing whether Read or Exists implementations are correctly removing resource from state, when it is gone currently requires significant number of LOC and leads to lack of such tests, which in turn then leads to bugs like this hashicorp/terraform#18931

The goal is to explore options for making such tests easier to write and generally making it easier to test such scenarios.


From @bflad :

This would save quite a few bug reports!

Would it make sense if this was a new boolean on TestStep? e.g. ExpectsRecreationIfDeleted (fixing my poor naming choice). It would automatically call the resource Delete function then ideally something similar to ExpectsNonEmptyPlan, but expecting a new resource in the difference rather than just any plan difference.

There are actually reasons to go beyond just a boolean here and instead accept a resource name from the Terraform state. Here's a great example: hashicorp/terraform-provider-aws#5914

Basically, ELBs can have children load balancer policies, which are wholly dependent on the ELB parent existing. In this case, for this acceptance testing I will actually need two separate TestStep's to verify the resource correctly catches both of the errors returned by the API:

  • One for removal of the load balancer policy (PolicyNotFound)
  • One for removal of the ELB (LoadBalancerNotFound)
@kmoe
Copy link
Member

kmoe commented Jan 27, 2020

Duplicate of hashicorp/terraform-plugin-testing#73.

@ghost
Copy link

ghost commented Feb 27, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Feb 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants