@aws-cdk_integ-tests-alpha.IApiCall

interface IApiCall ๐Ÿ”น

LanguageType name
.NETAmazon.CDK.IntegTests.Alpha.IApiCall
Gogithub.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#IApiCall
Javasoftware.amazon.awscdk.integtests.alpha.IApiCall
Pythonaws_cdk.integ_tests_alpha.IApiCall
TypeScript (source)@aws-cdk/integ-tests-alpha ยป IApiCall

Implemented by AwsApiCall, HttpApiCall, LambdaInvokeFunction

Obtainable from ApiCallBase.assertAtPath(), ApiCallBase.expect(), ApiCallBase.next(), ApiCallBase.waitForAssertions(), AwsApiCall.assertAtPath(), AwsApiCall.waitForAssertions(), HttpApiCall.assertAtPath(), HttpApiCall.waitForAssertions()

Represents an ApiCall.

Properties

NameTypeDescription
node๐Ÿ”นNodeThe tree node.
provider๐Ÿ”นAssertionsProvideraccess the AssertionsProvider.

node๐Ÿ”น

Type: Node

The tree node.


provider๐Ÿ”น

Type: AssertionsProvider

access the AssertionsProvider.

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

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

Methods

NameDescription
assertAtPath(path, expected)๐Ÿ”นAssert that the ExpectedResult is equal to the result of the AwsApiCall at the given path.
expect(expected)๐Ÿ”นAssert that the ExpectedResult is equal to the result of the AwsApiCall.
getAtt(attributeName)๐Ÿ”นReturns the value of an attribute of the custom resource of an arbitrary type.
getAttString(attributeName)๐Ÿ”นReturns the value of an attribute of the custom resource of type string.
next(next)๐Ÿ”นAllows you to chain IApiCalls. This adds an explicit dependency betweent the two resources.
waitForAssertions(options?)๐Ÿ”นWait for the IApiCall to return the expected response.

assertAtPath(path, expected)๐Ÿ”น

public assertAtPath(path: string, expected: ExpectedResult): IApiCall

Parameters

  • path string
  • expected ExpectedResult

Returns

  • 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

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)๐Ÿ”น

public expect(expected: ExpectedResult): IApiCall

Parameters

  • expected ExpectedResult

Returns

  • IApiCall

Assert that the ExpectedResult is equal to the result of the AwsApiCall. Example

declare const integ: IntegTest;
const invoke = integ.assertions.invokeFunction({
  functionName: 'my-func',
});
invoke.expect(ExpectedResult.objectLike({ Payload: 'OK' }));

getAtt(attributeName)๐Ÿ”น

public getAtt(attributeName: string): Reference

Parameters

  • attributeName string โ€” the name of the attribute.

Returns

  • 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.


getAttString(attributeName)๐Ÿ”น

public getAttString(attributeName: string): string

Parameters

  • attributeName string โ€” the name of the attribute.

Returns

  • 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.


next(next)๐Ÿ”น

public next(next: IApiCall): IApiCall

Parameters

  • next IApiCall

Returns

  • IApiCall

Allows you to chain IApiCalls. This adds an explicit dependency betweent the two resources.

Returns the IApiCall provided as next Example

declare const first: IApiCall;
declare const second: IApiCall;

first.next(second);

waitForAssertions(options?)๐Ÿ”น

public waitForAssertions(options?: WaiterStateMachineOptions): IApiCall

Parameters

  • options WaiterStateMachineOptions

Returns

  • 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

declare const integ: IntegTest;
declare const executionArn: string;
integ.assertions.awsApiCall('StepFunctions', 'describeExecution', {
   executionArn,
}).waitForAssertions();