Open timofurrer opened 2 years ago
Hi folks 👋
With the introduction of the terraform-plugin-testing module (migration guide), we are transferring feature requests relating to the helper/resource
"testing framework" in the terraform-plugin-sdk repository over to the new terraform-plugin-testing repository.
Thanks again for this feature request.
SDK version
Use-cases
In the Terraform Provider GitLab we have to setup testing resources (e.g. a project the resource under test resides in) in each test case.
At the moment we are creating them in each test case just before calling
resource.Test()
orresource.ParallelTest()
. However, that's a problem because when usingresource.ParallelTest()
this setup code isn't parallelized.We have a similar scenario for
resource.TestStep
where sometimes we have to introduce errors or other things and currently misusePreConfig
, but don't have a way for a proper teardown (t.Cleanup()
doesn't help if a subsequentTestStep
required that to happen)Attempted Solutions
Misusing
PreConfig
forTestStep
and defining setup / teardown outside ofresource.Test()
/resource.ParallelTest()
with be above mentioned limitations.Proposal
I don't have a concrete proposal, but envision some sort of
Setup
andTeardown
field registering some function onresource.Test()
/resource.ParallelTest()
andresource.TestStep()
level.The biggest challenge I see is how to pass data from
Setup
toTeardown
- this data would be necessary to cleanup properly. Another one is how to pass data fromSetup()
- fromresource.Test()
andresource.TestStep()
to e.g. theConfig
orCheck
?Questions