@@ -521,6 +521,79 @@ describe('#compileStateMachines', () => {
521521 . to . deep . eq ( [ { Key : 'team' , Value : 'core' } , { Key : 'score' , Value : '42' } ] ) ;
522522 } ) ;
523523
524+ it ( 'should add global tags' , ( ) => {
525+ serverless . service . provider . tags = {
526+ team : 'core' ,
527+ score : 42 ,
528+ } ;
529+
530+ serverless . service . stepFunctions = {
531+ stateMachines : {
532+ myStateMachine1 : {
533+ definition : 'definition1' ,
534+ name : 'stateMachineBeta1' ,
535+ } ,
536+ myStateMachine2 : {
537+ definition : 'definition2' ,
538+ name : 'stateMachineBeta2' ,
539+ } ,
540+ } ,
541+ } ;
542+
543+ serverlessStepFunctions . compileStateMachines ( ) ;
544+ const stateMachineBeta1 = serverlessStepFunctions . serverless . service
545+ . provider . compiledCloudFormationTemplate . Resources
546+ . StateMachineBeta1 ;
547+ const stateMachineBeta2 = serverlessStepFunctions . serverless . service
548+ . provider . compiledCloudFormationTemplate . Resources
549+ . StateMachineBeta2 ;
550+ expect ( stateMachineBeta1 . Properties . Tags ) . to . have . lengthOf ( 2 ) ;
551+ expect ( stateMachineBeta2 . Properties . Tags ) . to . have . lengthOf ( 2 ) ;
552+ expect ( stateMachineBeta1 . Properties . Tags )
553+ . to . deep . eq ( [ { Key : 'team' , Value : 'core' } , { Key : 'score' , Value : '42' } ] ) ;
554+ expect ( stateMachineBeta2 . Properties . Tags )
555+ . to . deep . eq ( [ { Key : 'team' , Value : 'core' } , { Key : 'score' , Value : '42' } ] ) ;
556+ } ) ;
557+
558+ it ( 'should merge global and state machine tags' , ( ) => {
559+ serverless . service . provider . tags = {
560+ team : 'core' ,
561+ } ;
562+
563+ serverless . service . stepFunctions = {
564+ stateMachines : {
565+ myStateMachine1 : {
566+ definition : 'definition1' ,
567+ name : 'stateMachineBeta1' ,
568+ tags : {
569+ score : 42 ,
570+ } ,
571+ } ,
572+ myStateMachine2 : {
573+ definition : 'definition2' ,
574+ name : 'stateMachineBeta2' ,
575+ tags : {
576+ score : 42 ,
577+ } ,
578+ } ,
579+ } ,
580+ } ;
581+
582+ serverlessStepFunctions . compileStateMachines ( ) ;
583+ const stateMachineBeta1 = serverlessStepFunctions . serverless . service
584+ . provider . compiledCloudFormationTemplate . Resources
585+ . StateMachineBeta1 ;
586+ const stateMachineBeta2 = serverlessStepFunctions . serverless . service
587+ . provider . compiledCloudFormationTemplate . Resources
588+ . StateMachineBeta2 ;
589+ expect ( stateMachineBeta1 . Properties . Tags ) . to . have . lengthOf ( 2 ) ;
590+ expect ( stateMachineBeta2 . Properties . Tags ) . to . have . lengthOf ( 2 ) ;
591+ expect ( stateMachineBeta1 . Properties . Tags )
592+ . to . deep . eq ( [ { Key : 'team' , Value : 'core' } , { Key : 'score' , Value : '42' } ] ) ;
593+ expect ( stateMachineBeta2 . Properties . Tags )
594+ . to . deep . eq ( [ { Key : 'team' , Value : 'core' } , { Key : 'score' , Value : '42' } ] ) ;
595+ } ) ;
596+
524597 it ( 'should throw error when tags property contains malformed tags' , ( ) => {
525598 serverless . service . stepFunctions = {
526599 stateMachines : {
0 commit comments