resource.Test(t, resource.TestCase{
PreCheck:func(){testAccPreCheck(t)},
ProtoV6ProviderFactories:map[string]func()(tfprotov6.ProviderServer,error){// newProvider is an example function that returns a tfsdk.Provider"example_provider": providerserver.NewProtocol6WithError(newProvider()),},
CheckDestroy: testAccCheckExampleResourceDestroy,
Steps:[]resource.TestStep{{
Config: testAccExampleResource,
Check: testAccCheckExampleResourceExists,},},})
resource.Test(t, resource.TestCase{ PreCheck:func(){testAccPreCheck(t)}, ProtoV6ProviderFactories:map[string]func()(tfprotov6.ProviderServer,error){// newProvider is an example function that returns a tfsdk.Provider"example_provider": providerserver.NewProtocol6WithError(newProvider()),}, CheckDestroy: testAccCheckExampleResourceDestroy, Steps:[]resource.TestStep{{ Config: testAccExampleResource, Check: testAccCheckExampleResourceExists,},},})
resource.Test(t, resource.TestCase{
PreCheck:func(){testAccPreCheck(t)},
ProtoV5ProviderFactories:map[string]func()(tfprotov5.ProviderServer,error){// newProvider is an example function that returns a tfsdk.Provider"example_provider": providerserver.NewProtocol5WithError(newProvider()),},
CheckDestroy: testAccCheckExampleResourceDestroy,
Steps:[]resource.TestStep{{
Config: testAccExampleResource,
Check: testAccCheckExampleResourceExists,},},})
resource.Test(t, resource.TestCase{ PreCheck:func(){testAccPreCheck(t)}, ProtoV5ProviderFactories:map[string]func()(tfprotov5.ProviderServer,error){// newProvider is an example function that returns a tfsdk.Provider"example_provider": providerserver.NewProtocol5WithError(newProvider()),}, CheckDestroy: testAccCheckExampleResourceDestroy, Steps:[]resource.TestStep{{ Config: testAccExampleResource, Check: testAccCheckExampleResourceExists,},},})
In SDKv2, resources and data sources automatically included an implicit, root level id attribute. In the framework, the id attribute is not implicitly added.
When testing resources and data sources without the id attribute, the acceptance testing framework will return errors such as:
testing_new_config.go:111: no "id" found in attributes
testing_new.go:53: no "id" found in attributes
testing_new_config.go:111: no "id" found in attributes
testing_new.go:53: no "id" found in attributes
To avoid this, add a root level id attribute to resource and data source schemas. Ensure the attribute value is appropriately written to state. Conventionally, id is a computed attribute that contains the identifier for the resource.