Skip to content

Commit

Permalink
add a test for Lambda function to take in task input as payload
Browse files Browse the repository at this point in the history
  • Loading branch information
shivlaks committed Apr 21, 2020
1 parent 4cae476 commit 05ec5d4
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,40 @@ test('Lambda function can be used in a Task with Task Token', () => {
});
});

test('Lambda function can be provided with the task input as the payload', () => {
const task = new sfn.Task(stack, 'Task', {
task: new tasks.RunLambdaTask(fn, {
payload: sfn.TaskInput.fromDataAt('$'),
}),
});
new sfn.StateMachine(stack, 'SM', {
definition: task,
});

expect(stack.resolve(task.toStateJson())).toEqual({
Type: 'Task',
Resource: {
'Fn::Join': [
'',
[
'arn:',
{
Ref: 'AWS::Partition',
},
':states:::lambda:invoke',
],
],
},
End: true,
Parameters: {
'FunctionName': {
Ref: 'Fn9270CBC0',
},
'Payload.$': '$',
},
});
});

test('Task throws if WAIT_FOR_TASK_TOKEN is supplied but task token is not included in payLoad', () => {
expect(() => {
new sfn.Task(stack, 'Task', {
Expand Down

0 comments on commit 05ec5d4

Please sign in to comment.