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
providerAssertionsProviderproviderAssertionsProviderproviderAssertionsProviderProviderAssertionsProviderProviderAssertionsProviderrequired#This can be used to add additional IAM policies the provider role policy
example
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#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
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#example
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#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#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.
next(next: IApiCall): IApiCall // chainabledef next(self, next: IApiCall) -> IApiCallpublic IApiCall next(IApiCall next)public IApiCall Next(IApiCall next)func Next(Next IApiCall) IApiCall#Returns the IApiCall provided as next
example
declare const first: IApiCall;
declare const second: IApiCall;
first.next(second);
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#If no expected response is specified then it will wait for the IApiCall to return a success
example
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#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