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

Support configurations in JSON syntax in the provider test framework #721

Closed
rudo-thomas opened this issue Mar 9, 2021 · 1 comment · Fixed by #722
Closed

Support configurations in JSON syntax in the provider test framework #721

rudo-thomas opened this issue Mar 9, 2021 · 1 comment · Fixed by #722
Assignees
Labels
enhancement New feature or request subsystem/tests Issues and feature requests related to the testing framework.
Milestone

Comments

@rudo-thomas
Copy link
Contributor

rudo-thomas commented Mar 9, 2021

SDK version

v2.4.4

Use-cases

The end goal is being able to use the JSON syntax when authoring provider tests.

Currently, you're forced to write the test configurations in the native syntax (see resource.TestStep.Config).

We're generating our Terraform configuration in JSON syntax. Having the feature would simplify testing the generated JSON with Terraform CLI directly (which is what resource.Test does), rather than passing the configuration through a conversion before feeding it to the test framework.

Attempted Solutions

As stated above, converting from the native syntax to JSON would work, but that adds a conversion layer that is not present outside of the tests. Outside of the tests, the JSON configuration is fed to Terraform CLI directly via *.tf.json files.

Proposal

(This is a revised proposal and now incorporates suggestions from this comment.)

Auto-detect whether resource.TestStep.Config contains valid JSON. When it does, the test framework will write out a .tf.json file, rather than a .tf one, before running the Terraform CLI.

I have a PR that achieves this: #722

References

@rudo-thomas rudo-thomas added the enhancement New feature or request label Mar 9, 2021
rudo-thomas added a commit to rudo-thomas/terraform-plugin-sdk that referenced this issue Mar 9, 2021
This implements the proposal described in hashicorp#721
@bflad bflad added the subsystem/tests Issues and feature requests related to the testing framework. label Oct 12, 2021
@bflad bflad self-assigned this Mar 11, 2022
@bflad bflad added this to the v2.12.0 milestone Mar 11, 2022
@bflad bflad linked a pull request Mar 11, 2022 that will close this issue
bflad pushed a commit that referenced this issue Mar 11, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request subsystem/tests Issues and feature requests related to the testing framework.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants