Hi Team ,
we are using terraform plugin framework(GitHub - hashicorp/terraform-plugin-framework: A next-generation framework for building Terraform providers.) to develop resources and data sources for our use case . For testing , we 're using github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource
I wanted to test my datasource where one attribute(let say id) is mandatorily needed from the user to fetch the data for that particular id .
There might be a situation where user doesn’t provide that id at all. So I wrote a test case for that where the config says as below :
data “abc_sp” “test21” {
names = [“pool1”]
}
Important Point to note is that I’m not providing the id in the above config. Just providing the name. So here while writing the acceptance test , I’m expecting an error "Error: Invalid Attribute Combination ".
{
Config: ProviderConfigForTesting + SPDataSourceWithoutID,
ExpectError: regexp.MustCompile(.*Error: Invalid Attribute Combination*.
),
},
When I run this test case , I’m getting an error as below :
Error running post-test destroy, there may be dangling resources: exit status 1
Error: Invalid Attribute Combination
with data.abc_sp.test21,
on terraform_plugin_test.tf line 8, in data "abc_sp" "test21":
8: data "abc_sp" "test21" {
No attribute specified when one (and only one) of [id] is
required
FAIL
FAIL terraform-provider/abc 20.084s
FAIL
I’m expecting this to pass as I’ve provided the correct error message in the Expect error section. But It says Error running post-test destroy, there may be dangling resources: exit status 1. May I know why is this happening??