@@ -1201,7 +1201,7 @@ describe('Deploy CloudFormation Stack', () => {
1201
1201
expect ( mockExecuteChangeSet ) . toHaveBeenCalledTimes ( 0 )
1202
1202
} )
1203
1203
1204
- test ( 'deploys the stack with template ' , async ( ) => {
1204
+ test ( 'deploys the stack with prefixed envs ' , async ( ) => {
1205
1205
const inputs : Inputs = {
1206
1206
name : 'MockStack' ,
1207
1207
template : 'template.yaml' ,
@@ -1225,6 +1225,8 @@ describe('Deploy CloudFormation Stack', () => {
1225
1225
1226
1226
await run ( )
1227
1227
1228
+ delete process . env . CFD_AdminNickname
1229
+
1228
1230
expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
1229
1231
expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
1230
1232
expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
@@ -1248,6 +1250,95 @@ describe('Deploy CloudFormation Stack', () => {
1248
1250
expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
1249
1251
} )
1250
1252
1253
+ test ( 'deploys the stack with prefixed envs but no envs are passed' , async ( ) => {
1254
+ const inputs : Inputs = {
1255
+ name : 'MockStack' ,
1256
+ template : 'template.yaml' ,
1257
+ capabilities : 'CAPABILITY_IAM' ,
1258
+ 'parameter-overrides' :
'[email protected] ' ,
1259
+ 'envs-prefix-for-parameter-overrides' : 'CFD_' ,
1260
+ 'no-fail-on-empty-changeset' : '0' ,
1261
+ 'disable-rollback' : '0' ,
1262
+ 'timeout-in-minutes' : '' ,
1263
+ 'notification-arns' : '' ,
1264
+ 'role-arn' : '' ,
1265
+ tags : '' ,
1266
+ 'termination-protection' : ''
1267
+ }
1268
+
1269
+ jest . spyOn ( core , 'getInput' ) . mockImplementation ( ( name : string ) => {
1270
+ return inputs [ name ]
1271
+ } )
1272
+
1273
+ await run ( )
1274
+
1275
+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
1276
+ expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
1277
+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
1278
+ StackName : 'MockStack'
1279
+ } )
1280
+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 2 , {
1281
+ StackName : mockStackId
1282
+ } )
1283
+ expect ( mockCreateStack ) . toHaveBeenNthCalledWith ( 1 , {
1284
+ StackName : 'MockStack' ,
1285
+ TemplateBody : mockTemplate ,
1286
+ Capabilities : [ 'CAPABILITY_IAM' ] ,
1287
+ Parameters : [
1288
+ { ParameterKey :
'AdminEmail' , ParameterValue :
'[email protected] ' }
1289
+ ] ,
1290
+ DisableRollback : false ,
1291
+ EnableTerminationProtection : false
1292
+ } )
1293
+ expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 )
1294
+ expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
1295
+ } )
1296
+
1297
+ test ( 'deploys the stack with prefixed envs but no other parameter overrides are passed' , async ( ) => {
1298
+ const inputs : Inputs = {
1299
+ name : 'MockStack' ,
1300
+ template : 'template.yaml' ,
1301
+ capabilities : 'CAPABILITY_IAM' ,
1302
+ 'envs-prefix-for-parameter-overrides' : 'CFD_' ,
1303
+ 'no-fail-on-empty-changeset' : '0' ,
1304
+ 'disable-rollback' : '0' ,
1305
+ 'timeout-in-minutes' : '' ,
1306
+ 'notification-arns' : '' ,
1307
+ 'role-arn' : '' ,
1308
+ tags : '' ,
1309
+ 'termination-protection' : ''
1310
+ }
1311
+
1312
+ jest . spyOn ( core , 'getInput' ) . mockImplementation ( ( name : string ) => {
1313
+ return inputs [ name ]
1314
+ } )
1315
+
1316
+ process . env = Object . assign ( process . env , { CFD_AdminNickname : 'root' } )
1317
+
1318
+ await run ( )
1319
+
1320
+ delete process . env . CFD_AdminNickname
1321
+
1322
+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 )
1323
+ expect ( mockDescribeStacks ) . toHaveBeenCalledTimes ( 2 )
1324
+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 1 , {
1325
+ StackName : 'MockStack'
1326
+ } )
1327
+ expect ( mockDescribeStacks ) . toHaveBeenNthCalledWith ( 2 , {
1328
+ StackName : mockStackId
1329
+ } )
1330
+ expect ( mockCreateStack ) . toHaveBeenNthCalledWith ( 1 , {
1331
+ StackName : 'MockStack' ,
1332
+ TemplateBody : mockTemplate ,
1333
+ Capabilities : [ 'CAPABILITY_IAM' ] ,
1334
+ Parameters : [ { ParameterKey : 'AdminNickname' , ParameterValue : 'root' } ] ,
1335
+ DisableRollback : false ,
1336
+ EnableTerminationProtection : false
1337
+ } )
1338
+ expect ( core . setOutput ) . toHaveBeenCalledTimes ( 1 )
1339
+ expect ( core . setOutput ) . toHaveBeenNthCalledWith ( 1 , 'stack-id' , mockStackId )
1340
+ } )
1341
+
1251
1342
test ( 'error is caught by core.setFailed' , async ( ) => {
1252
1343
mockDescribeStacks . mockReset ( )
1253
1344
mockDescribeStacks . mockImplementation ( ( ) => {
0 commit comments