-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aws-stepfunctions, aws-stepfunctions-tasks): missing suffix in fi… #2939
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a75dc02
fix(aws-stepfunctions, aws-stepfunctions-tasks): missing suffix in fi…
wqzoww dcf972b
Move renderObject() to consuming class so it can't be forgotten
rix0rrr c754c52
Merge branch 'master' into master
rix0rrr 9d529e3
Merge remote-tracking branch 'origin/master' into pr/wqzoww/2939
rix0rrr 125a259
feat(aws-stepfunctions-tasks) complete supporting parameters for lambda
wqzoww File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/@aws-cdk/aws-stepfunctions-tasks/test/run-lambda-task.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import '@aws-cdk/assert/jest'; | ||
import lambda = require('@aws-cdk/aws-lambda'); | ||
import sfn = require('@aws-cdk/aws-stepfunctions'); | ||
import { Stack } from '@aws-cdk/cdk'; | ||
import tasks = require('../lib'); | ||
|
||
let stack: Stack; | ||
let fn: lambda.Function; | ||
beforeEach(() => { | ||
stack = new Stack(); | ||
fn = new lambda.Function(stack, 'Fn', { | ||
code: lambda.Code.inline('hello'), | ||
handler: 'index.hello', | ||
runtime: lambda.Runtime.Python27, | ||
}); | ||
}); | ||
|
||
test('Invoke lambda with default magic ARN', () => { | ||
const task = new sfn.Task(stack, 'Task', { | ||
task: new tasks.RunLambdaTask(fn, { | ||
payload: { | ||
foo: 'bar' | ||
} | ||
}) | ||
}); | ||
new sfn.StateMachine(stack, 'SM', { | ||
definition: task | ||
}); | ||
|
||
expect(stack).toHaveResource('AWS::StepFunctions::StateMachine', { | ||
DefinitionString: { | ||
"Fn::Join": ["", [ | ||
"{\"StartAt\":\"Task\",\"States\":{\"Task\":{\"End\":true,\"Parameters\":{\"FunctionName\":\"", | ||
{ Ref: "Fn9270CBC0" }, | ||
"\",\"Payload\":{\"foo\":\"bar\"}},\"Type\":\"Task\",\"Resource\":\"arn:aws:states:::lambda:invoke\"}}}" | ||
]] | ||
}, | ||
}); | ||
}); | ||
|
||
test('Lambda function can be used in a Task with Task Token', () => { | ||
const task = new sfn.Task(stack, 'Task', { | ||
task: new tasks.RunLambdaTask(fn, { | ||
waitForTaskToken: true, | ||
payload: { | ||
token: sfn.Context.taskToken | ||
} | ||
}) | ||
}); | ||
new sfn.StateMachine(stack, 'SM', { | ||
definition: task | ||
}); | ||
|
||
expect(stack).toHaveResource('AWS::StepFunctions::StateMachine', { | ||
DefinitionString: { | ||
"Fn::Join": ["", [ | ||
"{\"StartAt\":\"Task\",\"States\":{\"Task\":{\"End\":true,\"Parameters\":{\"FunctionName\":\"", | ||
{ Ref: "Fn9270CBC0" }, | ||
"\",\"Payload\":{\"token.$\":\"$$.Task.Token\"}},\"Type\":\"Task\",\"Resource\":\"arn:aws:states:::lambda:invoke.waitForTaskToken\"}}}" | ||
]] | ||
}, | ||
}); | ||
}); | ||
|
||
test('Task throws if waitForTaskToken is supplied but task token is not included', () => { | ||
expect(() => { | ||
new sfn.Task(stack, 'Task', { | ||
task: new tasks.RunLambdaTask(fn, { | ||
waitForTaskToken: true | ||
}) | ||
}); | ||
}).toThrow(/Task Token is missing in payload/i); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be the responsibility of the individual tasks. It only makes sense in the
Parameters
field, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. I forgot the reference path only applies for
Parameters
field, rather than the entire block of state.