Repository navigation
Add retry plugin and related options #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
355d895
660d907
977060a
55053af
3cca041
3faaff9
e7dbaf0
6b09a22
eb0f407
ac0c7cb
d742690
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
|
|
||
| import {getRetryOptions} from '../src/retry-options' | ||
|
|
||
| describe('getRequestOptions', () => { | ||
| test('retries disabled if retries == 0', async () => { | ||
| const [retryOptions, requestOptions] = getRetryOptions(0, 8, [ | ||
| 400, | ||
| 500, | ||
| 502 | ||
| ]) | ||
|
|
||
| expect(retryOptions.enabled).toBe(false) | ||
| expect(retryOptions.doNotRetry).toBeFalsy() | ||
|
|
||
| expect(requestOptions.retries).toBeFalsy() | ||
| }) | ||
|
|
||
| test('properties set if retries > 0', async () => { | ||
| const [retryOptions, requestOptions] = getRetryOptions(1, 8, [ | ||
| 400, | ||
| 500, | ||
| 502 | ||
| ]) | ||
|
|
||
| expect(retryOptions.enabled).toBe(true) | ||
| expect(retryOptions.doNotRetry).toEqual([400, 500, 502]) | ||
|
|
||
| expect(requestOptions.retries).toEqual(1) | ||
| expect(requestOptions.retryAfter).toEqual(8) | ||
| }) | ||
|
|
||
| test('properties set if retries > 0', async () => { | ||
| const [retryOptions, requestOptions] = getRetryOptions(1, 8, [ | ||
| 400, | ||
| 500, | ||
| 502 | ||
| ]) | ||
|
|
||
| expect(retryOptions.enabled).toBe(true) | ||
| expect(retryOptions.doNotRetry).toEqual([400, 500, 502]) | ||
|
|
||
| expect(requestOptions.retries).toEqual(1) | ||
| expect(requestOptions.retryAfter).toEqual(8) | ||
| }) | ||
|
|
||
| test('retryAfter can be set to zero', async () => { | ||
| const [retryOptions, requestOptions] = getRetryOptions(1, 0, [ | ||
| 400, | ||
| 500, | ||
| 502 | ||
| ]) | ||
|
|
||
| expect(retryOptions.enabled).toBe(true) | ||
| expect(retryOptions.doNotRetry).toEqual([400, 500, 502]) | ||
|
|
||
| expect(requestOptions.retries).toEqual(1) | ||
| expect(requestOptions.retryAfter).toEqual(0) | ||
| }) | ||
|
|
||
| test('retryOptions.doNotRetry not set if doNotRetry isEmpty', async () => { | ||
| const [retryOptions, requestOptions] = getRetryOptions(1, 0, []) | ||
|
|
||
| expect(retryOptions.enabled).toBe(true) | ||
| expect(retryOptions.doNotRetry).toBeUndefined() | ||
|
|
||
| expect(requestOptions.retries).toEqual(1) | ||
| expect(requestOptions.retryAfter).toEqual(0) | ||
| }) | ||
| }) |
Uh oh!
There was an error while loading. Please reload this page.