assertions

package
v2.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture_IsMatcher

func Capture_IsMatcher(x interface{}) *bool

Check whether the provided object is a subtype of the `IMatcher`.

func Matcher_IsMatcher

func Matcher_IsMatcher(x interface{}) *bool

Check whether the provided object is a subtype of the `IMatcher`.

func NewCapture_Override

func NewCapture_Override(c Capture, pattern interface{})

Initialize a new capture.

func NewMatchResult_Override

func NewMatchResult_Override(m MatchResult, target interface{})

func NewMatch_Override

func NewMatch_Override(m Match)

func NewMatcher_Override

func NewMatcher_Override(m Matcher)

Types

type Annotations added in v2.10.0

type Annotations interface {
	FindError(constructPath *string, message interface{}) *[]*cxapi.SynthesisMessage
	FindInfo(constructPath *string, message interface{}) *[]*cxapi.SynthesisMessage
	FindWarning(constructPath *string, message interface{}) *[]*cxapi.SynthesisMessage
	HasError(constructPath *string, message interface{})
	HasInfo(constructPath *string, message interface{})
	HasWarning(constructPath *string, message interface{})
}

Suite of assertions that can be run on a CDK Stack.

Focused on asserting annotations.

TODO: EXAMPLE

func Annotations_FromStack added in v2.10.0

func Annotations_FromStack(stack awscdk.Stack) Annotations

Base your assertions on the messages returned by a synthesized CDK `Stack`.

type Capture

type Capture interface {
	Matcher
	Name() *string
	AsArray() *[]interface{}
	AsBoolean() *bool
	AsNumber() *float64
	AsObject() *map[string]interface{}
	AsString() *string
	Next() *bool
	Test(actual interface{}) MatchResult
}

Capture values while matching templates.

Using an instance of this class within a Matcher will capture the matching value. The `as*()` APIs on the instance can be used to get the captured value.

TODO: EXAMPLE

func NewCapture

func NewCapture(pattern interface{}) Capture

Initialize a new capture.

type Match

type Match interface {
}

Partial and special matching during template assertions.

type MatchCapture added in v2.1.0

type MatchCapture struct {
	// The instance of Capture class to which this capture is associated with.
	Capture Capture `json:"capture" yaml:"capture"`
	// The value that was captured.
	Value interface{} `json:"value" yaml:"value"`
}

Information about a value captured during match.

TODO: EXAMPLE

type MatchFailure added in v2.1.0

type MatchFailure struct {
	// The matcher that had the failure.
	Matcher Matcher `json:"matcher" yaml:"matcher"`
	// Failure message.
	Message *string `json:"message" yaml:"message"`
	// The relative path in the target where the failure occurred.
	//
	// If the failure occurred at root of the match tree, set the path to an empty list.
	// If it occurs in the 5th index of an array nested within the 'foo' key of an object,
	// set the path as `['/foo', '[5]']`.
	Path *[]*string `json:"path" yaml:"path"`
}

Match failure details.

TODO: EXAMPLE

type MatchResult

type MatchResult interface {
	FailCount() *float64
	Target() interface{}
	Compose(id *string, inner MatchResult) MatchResult
	Finished() MatchResult
	HasFailed() *bool
	Push(matcher Matcher, path *[]*string, message *string) MatchResult
	RecordCapture(options *MatchCapture)
	RecordFailure(failure *MatchFailure) MatchResult
	ToHumanStrings() *[]*string
}

The result of `Match.test()`.

TODO: EXAMPLE

func NewMatchResult

func NewMatchResult(target interface{}) MatchResult

type Matcher

type Matcher interface {
	Name() *string
	Test(actual interface{}) MatchResult
}

Represents a matcher that can perform special data matching capabilities between a given pattern and a target.

TODO: EXAMPLE

func Match_Absent

func Match_Absent() Matcher

Use this matcher in the place of a field's value, if the field must not be present.

func Match_AnyValue

func Match_AnyValue() Matcher

Matches any non-null value at the target.

func Match_ArrayEquals

func Match_ArrayEquals(pattern *[]interface{}) Matcher

Matches the specified pattern with the array found in the same relative path of the target.

The set of elements (or matchers) must match exactly and in order.

func Match_ArrayWith

func Match_ArrayWith(pattern *[]interface{}) Matcher

Matches the specified pattern with the array found in the same relative path of the target.

The set of elements (or matchers) must be in the same order as would be found.

func Match_Exact

func Match_Exact(pattern interface{}) Matcher

Deep exact matching of the specified pattern to the target.

func Match_Not

func Match_Not(pattern interface{}) Matcher

Matches any target which does NOT follow the specified pattern.

func Match_ObjectEquals

func Match_ObjectEquals(pattern *map[string]interface{}) Matcher

Matches the specified pattern to an object found in the same relative path of the target.

The keys and their values (or matchers) must match exactly with the target.

func Match_ObjectLike

func Match_ObjectLike(pattern *map[string]interface{}) Matcher

Matches the specified pattern to an object found in the same relative path of the target.

The keys and their values (or matchers) must be present in the target but the target can be a superset.

func Match_SerializedJson

func Match_SerializedJson(pattern interface{}) Matcher

Matches any string-encoded JSON and applies the specified pattern after parsing it.

func Match_StringLikeRegexp added in v2.9.0

func Match_StringLikeRegexp(pattern *string) Matcher

Matches targets according to a regular expression.

type Template

type Template interface {
	FindConditions(logicalId *string, props interface{}) *map[string]*map[string]interface{}
	FindMappings(logicalId *string, props interface{}) *map[string]*map[string]interface{}
	FindOutputs(logicalId *string, props interface{}) *map[string]*map[string]interface{}
	FindParameters(logicalId *string, props interface{}) *map[string]*map[string]interface{}
	FindResources(type_ *string, props interface{}) *map[string]*map[string]interface{}
	HasCondition(logicalId *string, props interface{})
	HasMapping(logicalId *string, props interface{})
	HasOutput(logicalId *string, props interface{})
	HasParameter(logicalId *string, props interface{})
	HasResource(type_ *string, props interface{})
	HasResourceProperties(type_ *string, props interface{})
	ResourceCountIs(type_ *string, count *float64)
	TemplateMatches(expected interface{})
	ToJSON() *map[string]interface{}
}

Suite of assertions that can be run on a CDK stack.

Typically used, as part of unit tests, to validate that the rendered CloudFormation template has expected resources and properties.

TODO: EXAMPLE

func Template_FromJSON

func Template_FromJSON(template *map[string]interface{}) Template

Base your assertions from an existing CloudFormation template formatted as an in-memory JSON object.

func Template_FromStack

func Template_FromStack(stack awscdk.Stack) Template

Base your assertions on the CloudFormation template synthesized by a CDK `Stack`.

func Template_FromString

func Template_FromString(template *string) Template

Base your assertions from an existing CloudFormation template formatted as a JSON string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL