Skip to content

Commit

Permalink
fix(stepfunctions): adds unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mshober committed Dec 20, 2019
1 parent 39053e6 commit 5c1a908
Showing 1 changed file with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, haveResource } from '@aws-cdk/assert';
import { expect, haveResource, ResourcePart } from '@aws-cdk/assert';
import * as iam from '@aws-cdk/aws-iam';
import * as cdk from '@aws-cdk/core';
import { Test } from 'nodeunit';
Expand Down Expand Up @@ -250,6 +250,37 @@ export = {
});

test.done();
}
},

'State machines must depend on their roles'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const task = new stepfunctions.Task(stack, 'Task', {
task: {
bind: () => ({
resourceArn: 'resource',
policyStatements: [
new iam.PolicyStatement({
resources: ['resource'],
actions: ["lambda:InvokeFunction"],
})
],
})
}
});
new stepfunctions.StateMachine(stack, 'StateMachine', {
definition: task
});

// THEN
expect(stack).to(haveResource('AWS::StepFunctions::StateMachine', {
DependsOn: [
'StateMachineRoleDefaultPolicyDF1E6607',
'StateMachineRoleB840431D'
]
}, ResourcePart.CompleteDefinition));

test.done();
},

};

0 comments on commit 5c1a908

Please sign in to comment.