Skip to content
v2.274.0

Experimental

@aws-cdk/integ-tests-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

IApiCall Interface ​

Represents an ApiCall.

Properties ​

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
access the AssertionsProvider.

This can be used to add additional IAM policies the provider role policy

example
ts
declare const apiCall: AwsApiCall;
apiCall.provider.addToRolePolicy({
  Effect: 'Allow',
  Action: ['s3:GetObject'],
  Resource: ['*'],
});

Methods ​

assertAtPath(path: string, expected: ExpectedResult): IApiCall // chainabledef assert_at_path(self, path: str, expected: ExpectedResult) -> IApiCallpublic IApiCall assertAtPath(String path, ExpectedResult expected)public IApiCall AssertAtPath(string path, ExpectedResult expected)func AssertAtPath(Path *string, Expected ExpectedResult) IApiCall#
Assert that the ExpectedResult is equal to the result of the AwsApiCall at the given path.

Providing a path will filter the output of the initial API call.

For example the SQS.receiveMessage api response would look like:

If you wanted to assert the value of Body you could do

example
ts
const actual = {
  Messages: [{
    MessageId: '',
    ReceiptHandle: '',
    MD5OfBody: '',
    Body: 'hello',
    Attributes: {},
    MD5OfMessageAttributes: {},
    MessageAttributes: {}
  }]
};


declare const integ: IntegTest;
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage');

message.assertAtPath('Messages.0.Body', ExpectedResult.stringLikeRegexp('hello'));
expect(expected: ExpectedResult): IApiCall // chainabledef expect(self, expected: ExpectedResult) -> IApiCallpublic IApiCall expect(ExpectedResult expected)public IApiCall Expect(ExpectedResult expected)func Expect(Expected ExpectedResult) IApiCall#
Assert that the ExpectedResult is equal to the result of the AwsApiCall.
example
ts
declare const integ: IntegTest;
const invoke = integ.assertions.invokeFunction({
  functionName: 'my-func',
});
invoke.expect(ExpectedResult.objectLike({ Payload: 'OK' }));
getAtt(attributeName: string): Referencedef get_att(self, attribute_name: str) -> Referencepublic Reference getAtt(String attributeName)public Reference GetAtt(string attributeName)func GetAtt(AttributeName *string) Reference#
Returns the value of an attribute of the custom resource of an arbitrary type.

Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.

1 parameter · returns

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — the name of the attribute.

Returns: a token for Fn::GetAtt. Use Token.asXxx to encode the returned Reference as a specific type or use the convenience getAttString for string attributes.

getAttString(attributeName: string): stringdef get_att_string(self, attribute_name: str) -> strpublic String getAttString(String attributeName)public string GetAttString(string attributeName)func GetAttString(AttributeName *string) *string#
Returns the value of an attribute of the custom resource of type string.

Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.

1 parameter · returns

Parameters

  • attributeNameattribute_nameattributeNameattributeNameAttributeName — the name of the attribute.

Returns: a token for Fn::GetAtt encoded as a string.

waitForAssertions(options?: WaiterStateMachineOptions): IApiCall // chainabledef wait_for_assertions(self, options: typing.Optional[WaiterStateMachineOptions] = None) -> IApiCallpublic IApiCall waitForAssertions(WaiterStateMachineOptions options)public IApiCall WaitForAssertions(WaiterStateMachineOptions? options = null)func WaitForAssertions(Options WaiterStateMachineOptions) IApiCall#
Wait for the IApiCall to return the expected response.

If no expected response is specified then it will wait for the IApiCall to return a success

example
ts
declare const integ: IntegTest;
declare const executionArn: string;
integ.assertions.awsApiCall('StepFunctions', 'describeExecution', {
   executionArn,
}).waitForAssertions();
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining