Skip to content

Commit a7d481b

Browse files
committed
changes to testing errors
1 parent 4a82be7 commit a7d481b

File tree

1 file changed

+61
-12
lines changed

1 file changed

+61
-12
lines changed

index.test.js

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,36 +1237,85 @@ describe('Deploy to ECS', () => {
12371237
});
12381238

12391239
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(
12411253
() => Promise.resolve({
12421254
failures: [{
12431255
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"
12451257
}],
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+
]
12481273
})
12491274
);
12501275

12511276
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");
12541278
});
12551279

12561280
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(
12581294
() => Promise.resolve({
12591295
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"
12621298
}],
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+
]
12641314
})
12651315
);
12661316

12671317
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");
12701319
});
12711320

12721321
test('error caught if AppSpec file is not formatted correctly', async () => {

0 commit comments

Comments
 (0)