interface IDeployAssert
Language | Type name |
---|---|
.NET | Amazon.CDK.IntegTests.Alpha.IDeployAssert |
Go | github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#IDeployAssert |
Java | software.amazon.awscdk.integtests.alpha.IDeployAssert |
Python | aws_cdk.integ_tests_alpha.IDeployAssert |
TypeScript (source) | @aws-cdk/integ-tests-alpha ยป IDeployAssert |
Interface that allows for registering a list of assertions that should be performed on a construct.
This is only necessary when writing integration tests.
Methods
Name | Description |
---|---|
aws | Query AWS using JavaScript SDK API calls. |
expect(id, expected, actual) | Assert that the ExpectedResult is equal to the ActualResult. |
http | Make an HTTP call to the provided endpoint. |
invoke | Invoke a lambda function and return the response which can be asserted. |
ApiCall(service, api, parameters?, outputPaths?)
awspublic awsApiCall(service: string, api: string, parameters?: any, outputPaths?: string[]): IApiCall
Parameters
- service
string
- api
string
- parameters
any
- outputPaths
string[]
Returns
Query AWS using JavaScript SDK API calls.
This can be used to either trigger an action or to return a result that can then be asserted against an expected value
The service
is the name of an AWS service, in one of the following forms:
- An AWS SDK for JavaScript v3 package name (
@aws-sdk/client-api-gateway
) - An AWS SDK for JavaScript v3 client name (
api-gateway
) - An AWS SDK for JavaScript v2 constructor name (
APIGateway
) - A lowercase AWS SDK for JavaScript v2 constructor name (
apigateway
)
The api
is the name of an AWS API call, in one of the following forms:
- An API call name as found in the API Reference documentation (
GetObject
) - The API call name starting with a lowercase letter (
getObject
) - The AWS SDK for JavaScript v3 command class name (
GetObjectCommand
) Example
declare const app: App;
declare const integ: IntegTest;
integ.assertions.awsApiCall('SQS', 'sendMessage', {
QueueUrl: 'url',
MessageBody: 'hello',
});
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: 'url',
});
message.expect(ExpectedResult.objectLike({
Messages: [{ Body: 'hello' }],
}));
expect(id, expected, actual)
public expect(id: string, expected: ExpectedResult, actual: ActualResult): void
Parameters
- id
string
- expected
Expected
Result - actual
Actual
Result
Assert that the ExpectedResult is equal to the ActualResult. Example
declare const integ: IntegTest;
declare const apiCall: AwsApiCall;
integ.assertions.expect(
'invoke',
ExpectedResult.objectLike({ Payload: 'OK' }),
ActualResult.fromAwsApiCall(apiCall, 'Body'),
);
ApiCall(url, options?)
httppublic httpApiCall(url: string, options?: FetchOptions): IApiCall
Parameters
- url
string
- options
Fetch
Options
Returns
Make an HTTP call to the provided endpoint. Example
declare const app: App;
declare const integ: IntegTest;
const call = integ.assertions.httpApiCall('https://example.com/test');
call.expect(ExpectedResult.objectLike({
Message: 'Hello World!',
}));
Function(props)
invokepublic invokeFunction(props: LambdaInvokeFunctionProps): IApiCall
Parameters
Returns
Invoke a lambda function and return the response which can be asserted. Example
declare const app: App;
declare const integ: IntegTest;
const invoke = integ.assertions.invokeFunction({
functionName: 'my-function',
});
invoke.expect(ExpectedResult.objectLike({
Payload: '200',
}));