hashicorp / hashicorp/terraform-plugin-testing
Consider documenting the specific terraform commands executed during acceptance tests
- Dominant language
- Go
- Stars
- 68
- Forks
- 22
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 1
Description
### Does this documentation exist?
* [ ] This is new documentation
* [x] This is an enhancement to existing documentation
### Where would you expect to find this documentation?
* [x] On terraform.io
* [ ] In the GoDoc for this module
* [ ] In this repo as a markdown file
* [ ] Somewhere else
#### Details
This documentation could appear in [Acceptance Tests](https://developer.hashicorp.com/terraform/plugin/testing/acceptance-tests) and provide details of the specific `terraform` commands that are executed during a particular "test mode".
For example, if an acceptance test is set-up to use `TestStep.Config`:
```go
func TestAccExampleResource(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read testing
{
Config: `resource "example_resource" "test" {
id = "one"
}`,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("example_resource.test", "configurable_attribute", "1.797693134862315"),
resource.TestCheckResourceAttr("example_resource.test", "id", "one"),
),
},
},
})
}
```
The following `terraform` commands are executed during the course of the test:
```shell
terraform init
terraform plan
terraform apply
terraform show (state)
terraform plan
terraform show (plan)
terraform plan
terraform show (plan)
terraform show (state)
terraform destroy
```
### Description
If the `terraform` command calls are documented and include details as to which flags are supplied (e.g., `-refresh-only`, `-refresh=true|false`) this might be useful for provider developers who are writing acceptance tests and aid in the generation of a mental model of which commands are being called and how this relates to direct execution of Terraform commands.
### References
- #238
- #223
Contributor guide
Assessment
This issue has not been assessed yet.