|
1 | 1 | import { Octokit } from '@octokit/rest'; |
| 2 | +import { RequestError } from '@octokit/request-error'; |
2 | 3 | import moment from 'moment'; |
3 | 4 | import nock from 'nock'; |
4 | 5 |
|
@@ -421,8 +422,13 @@ describe('Scale down runners', () => { |
421 | 422 | mockAwsRunners(runners); |
422 | 423 |
|
423 | 424 | // Mock 404 error response |
424 | | - const error404 = new Error('Runner not found'); |
425 | | - (error404 as any).status = 404; |
| 425 | + const error404 = new RequestError('Runner not found', 404, { |
| 426 | + request: { |
| 427 | + method: 'GET', |
| 428 | + url: 'https://api.github.com/test', |
| 429 | + headers: {}, |
| 430 | + }, |
| 431 | + }); |
426 | 432 |
|
427 | 433 | if (type === 'Repo') { |
428 | 434 | mockOctokit.actions.getSelfHostedRunnerForRepo.mockRejectedValueOnce(error404); |
@@ -453,8 +459,13 @@ describe('Scale down runners', () => { |
453 | 459 | mockAwsRunners(runners); |
454 | 460 |
|
455 | 461 | // Mock 404 error response for busy state check |
456 | | - const error404 = new Error('Runner not found'); |
457 | | - (error404 as any).status = 404; |
| 462 | + const error404 = new RequestError('Runner not found', 404, { |
| 463 | + request: { |
| 464 | + method: 'GET', |
| 465 | + url: 'https://api.github.com/test', |
| 466 | + headers: {}, |
| 467 | + }, |
| 468 | + }); |
458 | 469 |
|
459 | 470 | if (type === 'Repo') { |
460 | 471 | mockOctokit.actions.getSelfHostedRunnerForRepo.mockRejectedValueOnce(error404); |
@@ -487,8 +498,13 @@ describe('Scale down runners', () => { |
487 | 498 | mockAwsRunners(runners); |
488 | 499 |
|
489 | 500 | // Mock non-404 error response |
490 | | - const error500 = new Error('Internal server error'); |
491 | | - (error500 as any).status = 500; |
| 501 | + const error500 = new RequestError('Internal server error', 500, { |
| 502 | + request: { |
| 503 | + method: 'GET', |
| 504 | + url: 'https://api.github.com/test', |
| 505 | + headers: {}, |
| 506 | + }, |
| 507 | + }); |
492 | 508 |
|
493 | 509 | if (type === 'Repo') { |
494 | 510 | mockOctokit.actions.getSelfHostedRunnerForRepo.mockRejectedValueOnce(error500); |
|
0 commit comments