@@ -1389,7 +1389,7 @@ describe('Deploy CloudFormation Stack', () => {
1389
1389
expect ( mockCfnClient ) . toHaveReceivedCommandTimes ( ExecuteChangeSetCommand , 0 )
1390
1390
} )
1391
1391
1392
- test ( 'deploys the stack with template ' , async ( ) => {
1392
+ test ( 'deploys the stack with prefixed envs ' , async ( ) => {
1393
1393
const inputs : Inputs = {
1394
1394
name : 'MockStack' ,
1395
1395
template : 'template.yaml' ,
@@ -1413,6 +1413,8 @@ describe('Deploy CloudFormation Stack', () => {
1413
1413
1414
1414
await run ( )
1415
1415
1416
+ delete process . env . CFD_AdminNickname
1417
+
1416
1418
expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
1417
1419
expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
1418
1420
expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
@@ -1436,6 +1438,95 @@ describe('Deploy CloudFormation Stack', () => {
1436
1438
expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
1437
1439
} )
1438
1440
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' :
'[email protected] ' ,
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 :
'[email protected] ' }
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
+
1439
1530
test ( 'error is caught by core.setFailed' , async ( ) => {
1440
1531
mockCfnClient . reset ( ) . on ( DescribeStacksCommand ) . rejects ( new Error ( ) )
1441
1532
0 commit comments