hashicorp / hashicorp/terraform-plugin-testing

Consider allowing `PlanCheck` implementations to trigger `(*testing.T).Skip()`

Open
#108 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
68
Forks
22
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### Description
Plan Checks can currently return an error in `PlanCheckResponse.Error` to trigger the equivalent of `(*testing.T).Error()` and exit a test if the plan fails the assertion made. We should consider adding functionality to allow plan checks the ability to trigger `(*testing.T).Skip()` with a message.

For example, given a data source attribute value, skip the rest of this test. In the real world, this could be as trivial as a configuration such as:

```terraform
data "aws_partition" "test" {}

# ... other resource configuration ...
```

And wanting to skip the test if `data.aws_partition.test.name != "aws"` for services only available in the AWS Commercial partition.

This could prevent provider developers from needing to implement `TestCase.ErrorCheck` based on API error messaging they may not control.

### Proposal
Add a `Skip` string field to the `CheckPlanResponse` struct. Any plan check that sets this field would immediately invoke `(*testing.T).Skip(skipMsg)` with the string provided. All normal cleanup/defer functions should still be run - i.e. post-test destroy and temp file cleanup.

### References
- Dependent on Plan Check functionality #63

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.