-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
enhancementNew feature or requestNew feature or request
Description
terraform-plugin-testing version
github.com/hashicorp/terraform-plugin-testing v1.14.0-beta.1
Use cases
When making knownvalue checks on a resource returned by a query, it will be more readable to perform one lookup for the resource and then apply one or more knownvalue checks.
This will especially be the case when looking up a resource by an identity with multiple attributes is supported.
Proposal
Add a querycheck function, e.g. ExpectResourceKnownValues, which will take a list-resource address, a resource lookup mechanism (either by display name or resource identity), and one or more path and knownvalue check pairs.
For example:
querycheck.ExpectResourceKnownValues("example_resource", querycheck.ResourceByIdentity(...), []querycheck.KnownValueCheck{
querycheck.KnownValue(tfjsonpath.New("attr1"), knownvalue.NotNull()),
querycheck.KnownValue(tfjsonpath.New("name"), knownvalue.StringExact("example")),
})It will be an error if the lookup mechanism returns either zero or more than one result.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request