Value Comparers
Note
Value Comparers are for use in conjunction with State Checks, which leverage the terraform-json representation of Terraform state.
Value comparers can be used to assert a resource or data source attribute value across multiple Test Steps, like asserting that a randomly generated resource attribute doesn't change after multiple apply steps. This is done by creating the value comparer, typically before the test case is defined, using the relevant constructor function:
Once the value comparer is created, state values can be added in TestStep.ConfigStateChecks
:
The value comparer implementation (defined by the ValueComparer
interface) determines what assertion occurs when a state value is added. The built-in value comparers are:
Values Differ
The ValuesDiffer value comparer verifies that each value in the sequence of values supplied to the CompareValues()
method differs from the preceding value.
Example usage of ValuesDiffer in a CompareValue state check.
Values Same
The ValuesSame value comparer verifies that each value in the sequence of values supplied to the CompareValues()
method is the same as the preceding value.
Example usage of ValuesSame in a CompareValue state check.