Skip to content

Commit

Permalink
Add assertions to integ-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lagroujl committed Jun 12, 2024
1 parent a5c8057 commit da1d06c
Showing 1 changed file with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import { STANDARD_NODEJS_RUNTIME } from '../../config';
*/

class TestStack extends Stack {

readonly statemachine: sfn.StateMachine;

constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

Expand Down Expand Up @@ -43,7 +46,7 @@ class TestStack extends Stack {
role: customRole,
});

const statemachine = new sfn.StateMachine(this, 'StateMachine', {
this.statemachine = new sfn.StateMachine(this, 'StateMachine', {
definition: sum
.next(multiply)
.next(
Expand All @@ -55,16 +58,39 @@ class TestStack extends Stack {
});

new cdk.CfnOutput(this, 'StateMachineARN', {
value: statemachine.stateMachineArn,
value: this.statemachine.stateMachineArn,
});
}
}

const app = new App();

new integ.IntegTest(app, 'EvaluateExpressionInteg', {
testCases: [new TestStack(app, 'cdk-sfn-evaluate-expression-integ')],
const testStack = new TestStack(app, 'cdk-sfn-evaluate-expression-integ');

const testCase = new integ.IntegTest(app, 'EvaluateExpressionInteg', {
testCases: [testStack],
diffAssets: true,
});

const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', {
stateMachineArn: testStack.statemachine.stateMachineArn,
name: '309d2593-a5a2-4ea5-b401-f778ef06467c',
input: '{ "a": 3, "b": 4 }',
});

// describe the results of the execution
testCase.assertions
.awsApiCall(
'StepFunctions',
'describeExecution',
{
executionArn: start.getAttString('executionArn'),
})
.expect(integ.ExpectedResult.objectLike({
status: 'SUCCEEDED',
}))
.waitForAssertions({
totalTimeout: cdk.Duration.minutes(3),
});

app.synth();

0 comments on commit da1d06c

Please sign in to comment.