mirror of https://github.com/actions/toolkit
Refactor test to run status codes 1 by 1
parent
e6109ecebb
commit
c359bfc506
|
@ -24,6 +24,7 @@ jest.mock('@actions/http-client')
|
||||||
|
|
||||||
describe('Download Tests', () => {
|
describe('Download Tests', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
jest.setTimeout(300000);
|
||||||
await io.rmRF(root)
|
await io.rmRF(root)
|
||||||
await fs.mkdir(path.join(root), {
|
await fs.mkdir(path.join(root), {
|
||||||
recursive: true
|
recursive: true
|
||||||
|
@ -163,13 +164,19 @@ describe('Download Tests', () => {
|
||||||
await checkDestinationFile(targetPath, fileContents)
|
await checkDestinationFile(targetPath, fileContents)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Test retryable status codes during artifact download', async () => {
|
it.each([
|
||||||
|
429,
|
||||||
|
500,
|
||||||
|
502,
|
||||||
|
503,
|
||||||
|
504
|
||||||
|
])('Test retryable status code %p during artifact download', async (scode: number) => {
|
||||||
// The first http response should return a retryable status call while the subsequent call should return a 200 so
|
// The first http response should return a retryable status call while the subsequent call should return a 200 so
|
||||||
// the download should successfully finish
|
// the download should successfully finish
|
||||||
const retryableStatusCodes = [429, 500, 502, 503, 504]
|
const retryableStatusCodes = [scode]
|
||||||
for (const statusCode of retryableStatusCodes) {
|
for (const statusCode of retryableStatusCodes) {
|
||||||
const fileContents = Buffer.from('try, try again\n', defaultEncoding)
|
const fileContents = Buffer.from('try, try again\n', defaultEncoding)
|
||||||
const targetPath = path.join(root, `FileC-${statusCode}.txt`)
|
const targetPath = path.join(root, `AAAFileC-${statusCode}.txt`)
|
||||||
|
|
||||||
setupDownloadItemResponse(fileContents, false, statusCode, false, true)
|
setupDownloadItemResponse(fileContents, false, statusCode, false, true)
|
||||||
const downloadHttpClient = new DownloadHttpClient()
|
const downloadHttpClient = new DownloadHttpClient()
|
||||||
|
@ -186,7 +193,7 @@ describe('Download Tests', () => {
|
||||||
|
|
||||||
await checkDestinationFile(targetPath, fileContents)
|
await checkDestinationFile(targetPath, fileContents)
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
it('Test retry on truncated response with gzip', async () => {
|
it('Test retry on truncated response with gzip', async () => {
|
||||||
const fileContents = Buffer.from(
|
const fileContents = Buffer.from(
|
||||||
|
|
Loading…
Reference in New Issue