only retry downloadtool on 500s and 408 and 429 (#373)

This commit is contained in:
eric sciple
2020-03-09 14:35:53 -04:00
committed by GitHub
parent 82fbe5da0f
commit 5859d7172e
6 changed files with 136 additions and 38 deletions

View File

@@ -619,6 +619,39 @@ describe('@actions/tool-cache', function() {
expect(err.toString()).toContain('502')
}
})
it('retries 429s', async function() {
nock('http://example.com')
.get('/too-many-requests-429')
.times(2)
.reply(429, undefined)
nock('http://example.com')
.get('/too-many-requests-429')
.reply(500, undefined)
try {
const statusCodeUrl = 'http://example.com/too-many-requests-429'
await tc.downloadTool(statusCodeUrl)
} catch (err) {
expect(err.toString()).toContain('500')
}
})
it("doesn't retry 404", async function() {
nock('http://example.com')
.get('/not-found-404')
.reply(404, undefined)
nock('http://example.com')
.get('/not-found-404')
.reply(500, undefined)
try {
const statusCodeUrl = 'http://example.com/not-found-404'
await tc.downloadTool(statusCodeUrl)
} catch (err) {
expect(err.toString()).toContain('404')
}
})
})
/**