@@ -1237,36 +1237,85 @@ describe('Deploy to ECS', () => {
1237
1237
} ) ;
1238
1238
1239
1239
test ( 'error is caught if run task fails with (wait-for-task-stopped: true)' , async ( ) => {
1240
- mockEcsDescribeTasks . mockImplementation (
1240
+ core . getInput = jest
1241
+ . fn ( )
1242
+ . mockReturnValueOnce ( 'task-definition.json' ) // task-definition
1243
+ . mockReturnValueOnce ( '' ) // service
1244
+ . mockReturnValueOnce ( 'somecluster' ) // cluster
1245
+ . mockReturnValueOnce ( '' ) // wait-for-service-stability
1246
+ . mockReturnValueOnce ( '' ) // wait-for-minutes
1247
+ . mockReturnValueOnce ( '' ) // force-new-deployment
1248
+ . mockReturnValueOnce ( '' ) // desired-count
1249
+ . mockReturnValueOnce ( 'true' ) // run-task
1250
+ . mockReturnValueOnce ( 'true' ) ; // wait-for-task-stopped
1251
+
1252
+ mockRunTask . mockImplementation (
1241
1253
( ) => Promise . resolve ( {
1242
1254
failures : [ {
1243
1255
reason : 'TASK_FAILED' ,
1244
- arn : "arn:aws:ecs:us-east-1:111122223333 :task-definition/TaskFamilyName:* is TASK_FAILED "
1256
+ arn : "arn:aws:ecs:fake-region:account_id :task/arn "
1245
1257
} ] ,
1246
- tasks : [ ] ,
1247
- executionStoppedAt : 1
1258
+ tasks : [
1259
+ {
1260
+ containers : [
1261
+ {
1262
+ lastStatus : "RUNNING" ,
1263
+ exitCode : 0 ,
1264
+ reason : '' ,
1265
+ taskArn : "arn:aws:ecs:fake-region:account_id:task/arn"
1266
+ }
1267
+ ] ,
1268
+ desiredStatus : "RUNNING" ,
1269
+ lastStatus : "STOPPED" ,
1270
+ taskArn : "arn:aws:ecs:fake-region:account_id:task/arn"
1271
+ }
1272
+ ]
1248
1273
} )
1249
1274
) ;
1250
1275
1251
1276
await run ( ) ;
1252
- expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
1253
- expect ( mockEcsDescribeTasks ) . toHaveBeenCalledTimes ( 0 ) ;
1277
+ expect ( core . setFailed ) . toBeCalledWith ( "arn:aws:ecs:fake-region:account_id:task/arn is TASK_FAILED" ) ;
1254
1278
} ) ;
1255
1279
1256
1280
test ( 'error is caught if run task fails with (wait-for-task-stopped: true) and with service' , async ( ) => {
1257
- mockEcsDescribeTasks . mockImplementation (
1281
+ core . getInput = jest
1282
+ . fn ( )
1283
+ . mockReturnValueOnce ( 'task-definition.json' ) // task-definition
1284
+ . mockReturnValueOnce ( '' ) // service
1285
+ . mockReturnValueOnce ( 'somecluster' ) // cluster
1286
+ . mockReturnValueOnce ( '' ) // wait-for-service-stability
1287
+ . mockReturnValueOnce ( '' ) // wait-for-minutes
1288
+ . mockReturnValueOnce ( '' ) // force-new-deployment
1289
+ . mockReturnValueOnce ( '' ) // desired-count
1290
+ . mockReturnValueOnce ( 'true' ) // run-task
1291
+ . mockReturnValueOnce ( 'false' ) ; // wait-for-task-stopped
1292
+
1293
+ mockRunTask . mockImplementation (
1258
1294
( ) => Promise . resolve ( {
1259
1295
failures : [ {
1260
- reason : 'SERVICE_FAILED ' ,
1261
- arn : "arn:aws:ecs:us-east-1:111122223333:service/ServiceName "
1296
+ reason : 'TASK_FAILED ' ,
1297
+ arn : "arn:aws:ecs:fake-region:account_id:task/arn "
1262
1298
} ] ,
1263
- services : [ ] ,
1299
+ tasks : [
1300
+ {
1301
+ containers : [
1302
+ {
1303
+ lastStatus : "RUNNING" ,
1304
+ exitCode : 0 ,
1305
+ reason : '' ,
1306
+ taskArn : "arn:aws:ecs:fake-region:account_id:task/arn"
1307
+ }
1308
+ ] ,
1309
+ desiredStatus : "RUNNING" ,
1310
+ lastStatus : "STOPPED" ,
1311
+ taskArn : "arn:aws:ecs:fake-region:account_id:task/arn"
1312
+ }
1313
+ ]
1264
1314
} )
1265
1315
) ;
1266
1316
1267
1317
await run ( ) ;
1268
- expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
1269
- expect ( mockEcsDescribeTasks ) . toHaveBeenCalledTimes ( 0 ) ;
1318
+ expect ( core . setFailed ) . toBeCalledWith ( "arn:aws:ecs:fake-region:account_id:task/arn is TASK_FAILED" ) ;
1270
1319
} ) ;
1271
1320
1272
1321
test ( 'error caught if AppSpec file is not formatted correctly' , async ( ) => {
0 commit comments