interface IApiCall
Language | Type name |
---|---|
![]() | Amazon.CDK.IntegTests.Alpha.IApiCall |
![]() | github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#IApiCall |
![]() | software.amazon.awscdk.integtests.alpha.IApiCall |
![]() | aws_cdk.integ_tests_alpha.IApiCall |
![]() | @aws-cdk/integ-tests-alpha ยป IApiCall |
Implemented by
Aws
, Http
, Lambda
Obtainable from
Api
.assertAtPath()
, Api
.expect()
, Api
.next()
, Api
.waitForAssertions()
, Aws
.assertAtPath()
, Aws
.waitForAssertions()
, Http
.assertAtPath()
, Http
.waitForAssertions()
Represents an ApiCall.
Properties
Name | Type | Description |
---|---|---|
node | Node | The tree node. |
provider | Assertions | access the AssertionsProvider. |
node
Type:
Node
The tree node.
provider
Type:
Assertions
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
Name | Description |
---|---|
assert | 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. |
get | Returns the value of an attribute of the custom resource of an arbitrary type. |
get | 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. |
wait | Wait for the IApiCall to return the expected response. |
assertAtPath(path, expected)
public assertAtPath(path: string, expected: ExpectedResult): IApiCall
Parameters
- path
string
- expected
Expected
Result
Returns
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
Expected
Result
Returns
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
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
IApi
Call
Returns
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
Waiter
State Machine Options
Returns
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();