mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-28 18:26:15 +01:00
fix: Update tests to use new number of retries (#16346)
This commit is contained in:
parent
d371c8c1da
commit
72dd012cf2
@ -134,7 +134,7 @@ describe('runRetriableFunction', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('catches RetryError error and retries up to 5 times', async () => {
|
||||
it('catches RetryError error and retries up to 3 times', async () => {
|
||||
const tryFn = jest.fn().mockImplementation(() => {
|
||||
throw new RetryError()
|
||||
})
|
||||
@ -163,16 +163,14 @@ describe('runRetriableFunction', () => {
|
||||
|
||||
jest.runAllTimers()
|
||||
|
||||
await expect(promise).resolves.toEqual(5)
|
||||
expect(tryFn).toHaveBeenCalledTimes(5)
|
||||
await expect(promise).resolves.toEqual(3)
|
||||
expect(tryFn).toHaveBeenCalledTimes(3)
|
||||
expect(catchFn).toHaveBeenCalledTimes(1)
|
||||
expect(catchFn).toHaveBeenCalledWith(expect.any(RetryError))
|
||||
expect(finallyFn).toHaveBeenCalledTimes(1)
|
||||
expect(setTimeout).toHaveBeenCalledTimes(4)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 5_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 10_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(3, expect.any(Function), 20_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(4, expect.any(Function), 40_000)
|
||||
expect(setTimeout).toHaveBeenCalledTimes(2)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 3_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 6_000)
|
||||
expect(mockHub.appMetrics.queueError).toHaveBeenCalledWith(
|
||||
{
|
||||
...appMetric,
|
||||
@ -222,8 +220,8 @@ describe('runRetriableFunction', () => {
|
||||
expect(catchFn).toHaveBeenCalledTimes(0)
|
||||
expect(finallyFn).toHaveBeenCalledTimes(1)
|
||||
expect(setTimeout).toHaveBeenCalledTimes(2)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 5_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 10_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(1, expect.any(Function), 3_000)
|
||||
expect(setTimeout).toHaveBeenNthCalledWith(2, expect.any(Function), 6_000)
|
||||
expect(mockHub.appMetrics.queueMetric).toHaveBeenCalledWith({
|
||||
...appMetric,
|
||||
successes: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user