@@ -1389,7 +1389,7 @@ describe('Deploy CloudFormation Stack', () => {
13891389 expect ( mockCfnClient ) . toHaveReceivedCommandTimes ( ExecuteChangeSetCommand , 0 )
13901390 } )
13911391
1392- test ( 'deploys the stack with template ' , async ( ) => {
1392+ test ( 'deploys the stack with prefixed envs ' , async ( ) => {
13931393 const inputs : Inputs = {
13941394 name : 'MockStack' ,
13951395 template : 'template.yaml' ,
@@ -1413,6 +1413,8 @@ describe('Deploy CloudFormation Stack', () => {
14131413
14141414 await run ( )
14151415
1416+ delete process . env . CFD_AdminNickname
1417+
14161418 expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
14171419 expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
14181420 expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
@@ -1436,6 +1438,95 @@ describe('Deploy CloudFormation Stack', () => {
14361438 expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
14371439 } )
14381440
1441+ test ( 'deploys the stack with prefixed envs but no envs are passed' , async ( ) => {
1442+ const inputs : Inputs = {
1443+ name : 'MockStack' ,
1444+ template : 'template.yaml' ,
1445+ capabilities : 'CAPABILITY_IAM' ,
1446+ 'parameter-overrides' : 'AdminEmail=no-reply@amazon.com' ,
1447+ 'envs-prefix-for-parameter-overrides' : 'CFD_' ,
1448+ 'no-fail-on-empty-changeset' : '0' ,
1449+ 'disable-rollback' : '0' ,
1450+ 'timeout-in-minutes' : '' ,
1451+ 'notification-arns' : '' ,
1452+ 'role-arn' : '' ,
1453+ tags : '' ,
1454+ 'termination-protection' : ''
1455+ }
1456+
1457+ jest . spyOn ( core , 'getInput' ) . mockImplementation ( ( name : string ) => {
1458+ return inputs [ name ]
1459+ } )
1460+
1461+ await run ( )
1462+
1463+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
1464+ expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
1465+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
1466+ StackName : 'MockStack'
1467+ } )
1468+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 2 , {
1469+ StackName : mockStackId
1470+ } )
1471+ expect ( mockCreateStack ) . toHaveBeenNthCalledWith ( 1 , {
1472+ StackName : 'MockStack' ,
1473+ TemplateBody : mockTemplate ,
1474+ Capabilities : [ 'CAPABILITY_IAM' ] ,
1475+ Parameters : [
1476+ { ParameterKey : 'AdminEmail' , ParameterValue : 'no-reply@amazon.com' }
1477+ ] ,
1478+ DisableRollback : false ,
1479+ EnableTerminationProtection : false
1480+ } )
1481+ expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 )
1482+ expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
1483+ } )
1484+
1485+ test ( 'deploys the stack with prefixed envs but no other parameter overrides are passed' , async ( ) => {
1486+ const inputs : Inputs = {
1487+ name : 'MockStack' ,
1488+ template : 'template.yaml' ,
1489+ capabilities : 'CAPABILITY_IAM' ,
1490+ 'envs-prefix-for-parameter-overrides' : 'CFD_' ,
1491+ 'no-fail-on-empty-changeset' : '0' ,
1492+ 'disable-rollback' : '0' ,
1493+ 'timeout-in-minutes' : '' ,
1494+ 'notification-arns' : '' ,
1495+ 'role-arn' : '' ,
1496+ tags : '' ,
1497+ 'termination-protection' : ''
1498+ }
1499+
1500+ jest . spyOn ( core , 'getInput' ) . mockImplementation ( ( name : string ) => {
1501+ return inputs [ name ]
1502+ } )
1503+
1504+ process . env = Object . assign ( process . env , { CFD_AdminNickname : 'root' } )
1505+
1506+ await run ( )
1507+
1508+ delete process . env . CFD_AdminNickname
1509+
1510+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
1511+ expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
1512+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
1513+ StackName : 'MockStack'
1514+ } )
1515+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 2 , {
1516+ StackName : mockStackId
1517+ } )
1518+ expect ( mockCreateStack ) . toHaveBeenNthCalledWith ( 1 , {
1519+ StackName : 'MockStack' ,
1520+ TemplateBody : mockTemplate ,
1521+ Capabilities : [ 'CAPABILITY_IAM' ] ,
1522+ Parameters : [ { ParameterKey : 'AdminNickname' , ParameterValue : 'root' } ] ,
1523+ DisableRollback : false ,
1524+ EnableTerminationProtection : false
1525+ } )
1526+ expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 )
1527+ expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
1528+ } )
1529+
14391530 test ( 'error is caught by core.setFailed' , async ( ) => {
14401531 mockCfnClient . reset ( ) . on ( DescribeStacksCommand ) . rejects ( new Error ( ) )
14411532
0 commit comments