Documentation
¶
Overview ¶
Package querycheck contains the query check interface, request/response structs, and common query check implementations.
Index ¶
- type CheckQueryRequest
- type CheckQueryResponse
- type QueryResultCheck
- func ContainsResourceWithName(resourceAddress string, displayName string) QueryResultCheck
- func ExpectIdentity(resourceAddress string, identity map[string]knownvalue.Check) QueryResultCheck
- func ExpectKnownValue(listResourceAddress string, resourceName string, attributePath tfjsonpath.Path, ...) QueryResultCheck
- func ExpectLength(resourceAddress string, length int) QueryResultCheck
- func ExpectLengthAtLeast(resourceAddress string, length int) QueryResultCheck
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckQueryRequest ¶
type CheckQueryRequest struct {
// Query represents the parsed log messages relating to found resources returned by the `terraform query -json` command.
Query []tfjson.ListResourceFoundData
// QuerySummary contains a summary of the completed query operation
QuerySummary *tfjson.ListCompleteData
}
CheckQueryRequest is a request for an invoke of the CheckQuery function.
type CheckQueryResponse ¶
type CheckQueryResponse struct {
// Error is used to report the failure of a query check assertion and is combined with other QueryResultCheck errors
// to be reported as a test failure.
Error error
}
CheckQueryResponse is a response to an invoke of the CheckQuery function.
type QueryResultCheck ¶
type QueryResultCheck interface {
// CheckQuery should perform the query check.
CheckQuery(context.Context, CheckQueryRequest, *CheckQueryResponse)
}
QueryResultCheck defines an interface for implementing test logic to apply an assertion against a collection of found resources that were returned by a query. It returns an error if the query results do not match what is expected.
func ContainsResourceWithName ¶
func ContainsResourceWithName(resourceAddress string, displayName string) QueryResultCheck
ContainsResourceWithName returns a query check that asserts that a resource with a given display name exists within the returned results of the query.
This query check can only be used with managed resources that support query. Query is only supported in Terraform v1.14+
func ExpectIdentity ¶
func ExpectIdentity(resourceAddress string, identity map[string]knownvalue.Check) QueryResultCheck
ExpectIdentity returns a query check that asserts that the identity at the given resource matches a known object, where each map key represents an identity attribute name. The identity in query must exactly match the given object.
This query check can only be used with managed resources that support resource identity and query. Query is only supported in Terraform v1.14+
func ExpectKnownValue ¶
func ExpectKnownValue(listResourceAddress string, resourceName string, attributePath tfjsonpath.Path, knownValue knownvalue.Check) QueryResultCheck
ExpectKnownValue returns a query check that asserts the specified attribute values are present for a given resource object returned by a list query. The resource object can only be identified by providing the list resource address as well as the resource name (display name).
This query check can only be used with managed resources that support resource identity and query. Query is only supported in Terraform v1.14+
func ExpectLength ¶
func ExpectLength(resourceAddress string, length int) QueryResultCheck
ExpectLength returns a query check that asserts that the length of the query result is exactly the given value.
This query check can only be used with managed resources that support query. Query is only supported in Terraform v1.14+
func ExpectLengthAtLeast ¶
func ExpectLengthAtLeast(resourceAddress string, length int) QueryResultCheck
ExpectLengthAtLeast returns a query check that asserts that the length of the query result is at least the given value.
This query check can only be used with managed resources that support query. Query is only supported in Terraform v1.14+