-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update
StateMachineStage
to use definitionBody
instead of d…
…eprecated `definition` (#372) * update definition -> definitionBody * adding tests and updating props in stages
- Loading branch information
1 parent
72fbb56
commit b0107df
Showing
15 changed files
with
491 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import * as cdk from "aws-cdk-lib"; | ||
import * as events from "aws-cdk-lib/aws-events"; | ||
import * as sfn from "aws-cdk-lib/aws-stepfunctions"; | ||
import { Construct } from "constructs"; | ||
|
||
import { StateMachineStage, StateMachineStageProps } from "../src"; | ||
|
||
class TestSFNStage extends StateMachineStage { | ||
readonly targets?: events.IRuleTarget[]; | ||
readonly eventPattern?: events.EventPattern; | ||
readonly stateMachine: sfn.StateMachine; | ||
|
||
constructor(scope: Construct, id: string, props: StateMachineStageProps) { | ||
super(scope, id, props); | ||
({ | ||
eventPattern: this.eventPattern, | ||
targets: this.targets, | ||
stateMachine: this.stateMachine, | ||
} = this.createStateMachine({ | ||
definition: props.definition, | ||
definitionFile: props.definitionFile, | ||
...props, | ||
})); | ||
} | ||
} | ||
|
||
test("State Machine Stage Definition File", () => { | ||
const stack = new cdk.Stack(); | ||
new TestSFNStage(stack, "MySFN", { | ||
definitionFile: "./test/test-sfn-config.json", | ||
}); | ||
}); | ||
|
||
test("State Machine Stage Definition String", () => { | ||
const stack = new cdk.Stack(); | ||
new TestSFNStage(stack, "MySFN", { | ||
definition: '{"StartAt":"Pass","States":{"Pass":{"Type":"Pass","End":true}}}', | ||
}); | ||
}); | ||
|
||
test("SFN No Definition", () => { | ||
const stack = new cdk.Stack(); | ||
expect(() => { | ||
new TestSFNStage(stack, "MySFN", {}); | ||
}).toThrowError("One of 'definition' or 'definitionFile' must be provided."); | ||
}); | ||
|
||
test("SFN Redundant Definitions", () => { | ||
const stack = new cdk.Stack(); | ||
expect(() => { | ||
new TestSFNStage(stack, "MySFN", { | ||
definition: '{"StartAt":"Pass","States":{"Pass":{"Type":"Pass","End":true}}}', | ||
definitionFile: "./test/test-sfn-config.json", | ||
}); | ||
}).toThrowError("Only one of 'definition' or 'definitionFile' should be provided."); | ||
}); |
Oops, something went wrong.