mirror of
https://code.forgejo.org/actions/checkout.git
synced 2025-04-28 22:25:54 +00:00
add options to set max attempts and intervals
This commit is contained in:
parent
2d7d9f7ff5
commit
4dca78049b
8 changed files with 85 additions and 3 deletions
|
@ -84,4 +84,28 @@ describe('retry-helper tests', () => {
|
|||
expect(info[2]).toBe('some error 2')
|
||||
expect(info[3]).toMatch(/Waiting .+ seconds before trying again/)
|
||||
})
|
||||
|
||||
it('should be able to set max attempts', async () => {
|
||||
let attempts = 0
|
||||
let error: Error = null as unknown as Error
|
||||
try {
|
||||
retryHelper.config(5, 1, 5)
|
||||
await retryHelper.execute(() => {
|
||||
throw new Error(`some error ${++attempts}`)
|
||||
})
|
||||
} catch (err) {
|
||||
error = err as Error
|
||||
}
|
||||
expect(error.message).toBe('some error 5')
|
||||
expect(attempts).toBe(5)
|
||||
expect(info).toHaveLength(6)
|
||||
expect(info[0]).toBe('some error 1')
|
||||
expect(info[1]).toMatch(/Waiting .+ seconds before trying again/)
|
||||
expect(info[2]).toBe('some error 2')
|
||||
expect(info[3]).toMatch(/Waiting .+ seconds before trying again/)
|
||||
expect(info[4]).toBe('some error 3')
|
||||
expect(info[5]).toMatch(/Waiting .+ seconds before trying again/)
|
||||
expect(info[6]).toBe('some error 4')
|
||||
expect(info[7]).toMatch(/Waiting .+ seconds before trying again/)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue