Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New TestCheck helper TestCheckResourceAttrPairWith #187

Open
ewbankkit opened this issue Sep 12, 2023 · 1 comment
Open

New TestCheck helper TestCheckResourceAttrPairWith #187

ewbankkit opened this issue Sep 12, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@ewbankkit
Copy link
Contributor

terraform-plugin-testing version

% go list -m github.com/hashicorp/terraform-plugin-testing/...
github.com/hashicorp/terraform-plugin-testing v1.5.1

Use cases

It would be handy to have a new TestCheck helper function that combines TestCheckResourceAttrWith and TestCheckResourceAttrPair, say TestCheckResourceAttrPairWith:

type CheckResourceAttrPairWithFunc func(valueFirst, valueSecond string) error

func TestCheckResourceAttrPairWith(nameFirst, keyFirst, nameSecond, keySecond string, checkValuesFunc CheckResourceAttrPairWithFunc) TestCheckFunc {
...
}

The canonical use case for the Terraform AWS Provider is to test logical equivalence (rather than byte-for-byte equivalence) of a data source's IAM policy document and a resource's IAM policy document.

@ewbankkit ewbankkit added the enhancement New feature or request label Sep 12, 2023
@bendbennett
Copy link
Contributor

The proposed ValueComparer interface in #295 could be something that provides way to achieve the equivalent of TestCheckResourceAttrPairWith as a "custom" comparer could be supplied to a CompareValuePairs constructor. For example:

func CompareValuePairs(resourceAddressOne string, attributePathOne tfjsonpath.Path, resourceAddressTwo string, attributePathTwo tfjsonpath.Path, comparer compare.ValueComparer) StateCheck {
	return &compareValuePairs{
		resourceAddressOne: resourceAddressOne,
		attributePathOne:   attributePathOne,
		resourceAddressTwo: resourceAddressTwo,
		attributePathTwo:   attributePathTwo,
		comparer:           comparer,
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants