File tree Expand file tree Collapse file tree 2 files changed +82
-1
lines changed Expand file tree Collapse file tree 2 files changed +82
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ function getTaskStates(states) {
1919 return getTaskStates ( parallelStates ) ;
2020 }
2121 case 'Map' : {
22- const mapStates = state . Iterator . States ;
22+ const mapStates = state . ItemProcessor ? state . ItemProcessor . States : state . Iterator . States ;
2323 return getTaskStates ( mapStates ) ;
2424 }
2525 default : {
Original file line number Diff line number Diff line change @@ -1647,4 +1647,85 @@ describe('#compileStateMachines', () => {
16471647 // Definition is invalid and validate=true, should throw
16481648 expect ( ( ) => serverlessStepFunctions . compileStateMachines ( ) ) . to . throw ( Error ) ;
16491649 } ) ;
1650+
1651+ it ( 'should compile with the old Iterator' , ( ) => {
1652+ serverless . service . stepFunctions = {
1653+ stateMachines : {
1654+ myStateMachine1 : {
1655+ id : 'Test' ,
1656+ name : 'test' ,
1657+ definition : {
1658+ StartAt : 'One' ,
1659+ States : {
1660+ One : {
1661+ Type : 'Map' ,
1662+ Iterator : {
1663+ StartAt : 'Two' ,
1664+ States : {
1665+ Two : {
1666+ Type : 'Wait' ,
1667+ Seconds : 10 ,
1668+ End : true ,
1669+ } ,
1670+ } ,
1671+ } ,
1672+ End : true ,
1673+ } ,
1674+ } ,
1675+ } ,
1676+ } ,
1677+ } ,
1678+ } ;
1679+
1680+ serverlessStepFunctions . compileStateMachines ( ) ;
1681+ const stateMachine = serverlessStepFunctions . serverless . service
1682+ . provider . compiledCloudFormationTemplate . Resources
1683+ . Test ;
1684+
1685+ expect ( stateMachine . Properties . DefinitionString ) . to . not . haveOwnProperty ( 'Fn::Sub' ) ;
1686+ const stateMachineObj = JSON . parse ( stateMachine . Properties . DefinitionString ) ;
1687+ expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'One' ) ;
1688+ } ) ;
1689+
1690+ it ( 'should compile with the new ItemProcessor' , ( ) => {
1691+ serverless . service . stepFunctions = {
1692+ stateMachines : {
1693+ myStateMachine1 : {
1694+ id : 'Test' ,
1695+ name : 'test' ,
1696+ definition : {
1697+ StartAt : 'One' ,
1698+ States : {
1699+ One : {
1700+ Type : 'Map' ,
1701+ ItemProcessor : {
1702+ ProcessorConfig : {
1703+ Mode : 'INLINE' ,
1704+ } ,
1705+ StartAt : 'Two' ,
1706+ States : {
1707+ Two : {
1708+ Type : 'Wait' ,
1709+ Seconds : 10 ,
1710+ End : true ,
1711+ } ,
1712+ } ,
1713+ } ,
1714+ End : true ,
1715+ } ,
1716+ } ,
1717+ } ,
1718+ } ,
1719+ } ,
1720+ } ;
1721+
1722+ serverlessStepFunctions . compileStateMachines ( ) ;
1723+ const stateMachine = serverlessStepFunctions . serverless . service
1724+ . provider . compiledCloudFormationTemplate . Resources
1725+ . Test ;
1726+
1727+ expect ( stateMachine . Properties . DefinitionString ) . to . not . haveOwnProperty ( 'Fn::Sub' ) ;
1728+ const stateMachineObj = JSON . parse ( stateMachine . Properties . DefinitionString ) ;
1729+ expect ( stateMachineObj . States ) . to . haveOwnProperty ( 'One' ) ;
1730+ } ) ;
16501731} ) ;
You can’t perform that action at this time.
0 commit comments