Documentation
¶
Overview ¶
Package querycheck contains the query check interface, request/response structs, and common query check implementations.
Index ¶
- type CheckQueryRequest
- type CheckQueryResponse
- type KnownValueCheck
- type QueryResultCheck
- func ExpectIdentity(resourceAddress string, identity map[string]knownvalue.Check) QueryResultCheck
- func ExpectLength(resourceAddress string, length int) QueryResultCheck
- func ExpectLengthAtLeast(resourceAddress string, length int) QueryResultCheck
- func ExpectNoIdentity(resourceAddress string, identity map[string]knownvalue.Check) QueryResultCheck
- func ExpectResourceDisplayName(listResourceAddress string, filter queryfilter.QueryFilter, ...) QueryResultCheck
- func ExpectResourceKnownValues(listResourceAddress string, filter queryfilter.QueryFilter, ...) QueryResultCheck
- type QueryResultCheckWithFilters
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 KnownValueCheck ¶
type KnownValueCheck struct {
// Path specifies the JSON path to check within the resource object.
Path tfjsonpath.Path
// KnownValue specifies the expected known value check to perform at the given path.
KnownValue knownvalue.Check
}
KnownValueCheck represents a check of a known value at a specific JSON path and is used to specify multiple known value checks to assert against a single resource object returned by a query.
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 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 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+
func ExpectNoIdentity ¶
func ExpectNoIdentity(resourceAddress string, identity map[string]knownvalue.Check) QueryResultCheck
ExpectNoIdentity returns a query check that asserts that the identity at the given resource does not match 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 ExpectResourceDisplayName ¶
func ExpectResourceDisplayName(listResourceAddress string, filter queryfilter.QueryFilter, displayName knownvalue.Check) QueryResultCheck
ExpectResourceDisplayName 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 ExpectResourceKnownValues ¶
func ExpectResourceKnownValues(listResourceAddress string, filter queryfilter.QueryFilter, knownValues []KnownValueCheck) QueryResultCheck
ExpectResourceKnownValues returns a query check which asserts that a resource object identified by a query filter passes the given query checks.
This query check can only be used with managed resources that support resource identity and query. Query is only supported in Terraform v1.14+
type QueryResultCheckWithFilters ¶
type QueryResultCheckWithFilters interface {
QueryResultCheck
// QueryFilters should return a slice of queryfilter.QueryFilter that will be applied to the check.
QueryFilters(context.Context) []queryfilter.QueryFilter
}
QueryResultCheckWithFilters is an interface type that extends QueryResultCheck to include declarative query filters.