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

Testing - Add a test step check to verify a resource was NOT destroyed+recreated #12428

Open
c2thorn opened this issue Aug 30, 2022 · 2 comments

Comments

@c2thorn
Copy link
Collaborator

c2thorn commented Aug 30, 2022

Historically we have relied on manual log review to verify that a resource was updated in place vs simply destroyed/recreated. This leads to gaps where update functions are unintentionally untested, since the test will still pass when the resource is recreated.

We should provide a common test step check function that will verify that the resource was not destroyed during the current step. We should also document it here: https://github.com/GoogleCloudPlatform/magic-modules/tree/main/mmv1/third_party/terraform#update-tests

@melinath
Copy link
Collaborator

melinath commented Aug 30, 2022

It would be great to provide guidance on how to ensure that you are not deleting a resource during the update test:

  • Avoiding changes to ForceNew fields
  • lifecyle.prevent_destroy = true

@rileykarson
Copy link
Collaborator

PlanCheck should allow us to assert this now: https://github.com/hashicorp/terraform-plugin-testing/releases/tag/v1.2.0

Sizing up since I think this requires switching to the new dedicated Go module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants