hashicorp / hashicorp/terraform-plugin-testing

Sweeper '-sweep-run' flag to use regexp match when filtering sweepers to run

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

Description

### SDK version

```
$ go mod edit -json | jq '.Require[] | select(.Path=="github.com/hashicorp/terraform-plugin-sdk")'
{
"Path": "github.com/hashicorp/terraform-plugin-sdk",
"Version": "v1.4.0"
}
```

### Use-cases

When running something like

```
$ TEST=./aws SWEEP=us-west-2 SWEEPARGS=-sweep-run=aws_xxx make sweep
```

the sweeper for resources like `aws_xxx_attachment` are run even if they are not declared as dependencies of `aws_xxx`.
This is because [`filterSweepers()`](https://github.com/hashicorp/terraform-plugin-sdk/blob/22ad3149e8cae475a3fd3bd3eb48000b04c826d1/helper/resource/testing.go#L169) uses `strings.Contains()` on the sweeper name to determine if it should be run.
Changing this to a regexp match would allow exact matches (`^aws_xxx$`) as well as being backwards compatible.

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.