hashicorp / hashicorp/terraform-plugin-testing
actions: Add functionality to allow assertions on progress messages returned from invoke
- Dominant language
- Go
- Stars
- 68
- Forks
- 22
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 1
Description
### terraform-plugin-testing version
```
github.com/hashicorp/terraform-plugin-testing v1.15.0
```
### Use cases
When a Terraform action is being invoked it can [send progress messages](https://developer.hashicorp.com/terraform/plugin/framework/actions/implementation#sending-progress-messages), which the Terraform UI displays upon receiving: https://github.com/hashicorp/terraform/blob/a47b89170f40e7deaf72e543a86660060f83d4e8/internal/terraform/node_action_trigger_instance_apply.go#L168-L174 .
Since these progress messages are produced by provider action code, it might be desirable to write test assertions against said progress messages with `terraform-plugin-testing`.
### Proposal
Since Terraform doesn't store the action progress messages in any artifact (like the state or plan file), `terraform-plugin-testing` has limited options for retrieving the progress message.
One potential idea is to grab the action's progress message from the console output (likely via JSON), which we would need to do some decent-size refactoring to achieve with our current setup of testing errors with `Config` mode, which is what paused the warning assertion work (https://github.com/hashicorp/terraform-plugin-testing/issues/69, https://github.com/hashicorp/terraform-plugin-testing/pull/17#discussion_r1095024348).
Another idea is to wrap the provider itself with a test spy to record the actual protocol messages that go between the provider and Terraform as they run, an implementation of this idea was proposed in https://github.com/hashicorp/terraform-plugin-testing/pull/570
-----
If you have use-cases for testing progress messages, please share them here!
### References
- Originally discussed in #557
Contributor guide
Assessment
This issue has not been assessed yet.