Experimental
@aws-cdk/integ-tests-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
IDeployAssert Interface
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
awsApiCall(service: string, api: string, parameters?: any, outputPaths?: string[]): IApiCalldef aws_api_call(self, service: str, api: str, parameters: typing.Optional[Any] = None, output_paths: typing.Optional[typing.List[str]] = None) -> IApiCallpublic IApiCall awsApiCall(String service, String api, Object parameters, List<String> outputPaths)public IApiCall AwsApiCall(string service, string api, object? parameters = null, string[]? outputPaths = null)func AwsApiCall(Service *string, Api *string, Parameters interface{}, OutputPaths *[]*string) IApiCall#Query AWS using JavaScript SDK API calls.
notes · example
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)
ts
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: string, expected: ExpectedResult, actual: ActualResult): voiddef expect(self, id: str, expected: ExpectedResult, actual: ActualResult) -> Nonepublic void expect(String id, ExpectedResult expected, ActualResult actual)public void Expect(string id, ExpectedResult expected, ActualResult actual)func Expect(Id *string, Expected ExpectedResult, Actual ActualResult)#Assert that the ExpectedResult is equal to the ActualResult.
example
ts
declare const integ: IntegTest;
declare const apiCall: AwsApiCall;
integ.assertions.expect(
'invoke',
ExpectedResult.objectLike({ Payload: 'OK' }),
ActualResult.fromAwsApiCall(apiCall, 'Body'),
);
httpApiCall(url: string, options?: FetchOptions): IApiCalldef http_api_call(self, url: str, options: typing.Optional[FetchOptions] = None) -> IApiCallpublic IApiCall httpApiCall(String url, FetchOptions options)public IApiCall HttpApiCall(string url, FetchOptions? options = null)func HttpApiCall(Url *string, Options FetchOptions) IApiCall#Make an HTTP call to the provided endpoint.
example
ts
declare const app: App;
declare const integ: IntegTest;
const call = integ.assertions.httpApiCall('https://example.com/test');
call.expect(ExpectedResult.objectLike({
Message: 'Hello World!',
}));
invokeFunction(props: LambdaInvokeFunctionProps): IApiCalldef invoke_function(self, props: LambdaInvokeFunctionProps) -> IApiCallpublic IApiCall invokeFunction(LambdaInvokeFunctionProps props)public IApiCall InvokeFunction(LambdaInvokeFunctionProps props)func InvokeFunction(Props LambdaInvokeFunctionProps) IApiCall#Invoke a lambda function and return the response which can be asserted.
example
ts
declare const app: App;
declare const integ: IntegTest;
const invoke = integ.assertions.invokeFunction({
functionName: 'my-function',
});
invoke.expect(ExpectedResult.objectLike({
Payload: '200',
}));