Hello,
We wrote a provider with the new GitHub - hashicorp/terraform-plugin-framework: A next-generation framework for building Terraform providers.
We use some provider.ConfigValidators and they work fine
We would like to add tests for them. How to do that for a provider, if possible ?
We successfully wrote some for our datasource/resource but looks like the provider must work differently ?
Thank you
Hi @Khyme Welcome to HashiCorp Discuss and thank you for raising this topic. Great question.
If you are looking to create acceptance tests for provider configuration validation, the trick there is ensuring the Terraform configuration in the test contains at least one valid data source or resource for the provider. Terraform core may not call provider configuration validation and the provider’s Configure
method unless it can determine that configuring the provider is actually necessary.
Here are some code examples from HashiCorp-owned providers:
- terraform-provider-dns/provider_test.go at cb011c7f7965dbe5454f837d2e314b83afa672b3 · hashicorp/terraform-provider-dns · GitHub
- terraform-provider-tls/provider_test.go at 66911e12898dd0b47abb11dd991abe868d8b76bd · hashicorp/terraform-provider-tls · GitHub
Hope this helps!