perf(reconcile): chunked Promise.all in member loop
This commit is contained in:
parent
678fdfe388
commit
a6304e1c23
2 changed files with 36 additions and 17 deletions
|
|
@ -162,12 +162,12 @@ describe('POST /api/internal/reconcile-payments', () => {
|
|||
{ _id: 'm3', helcimCustomerId: 'cust-3' }
|
||||
]))
|
||||
// m1 succeeds first try, m2 fails all 3 retries, m3 succeeds first try.
|
||||
listHelcimCustomerTransactions
|
||||
.mockResolvedValueOnce([{ id: 'tx1', status: 'paid', amount: 5 }])
|
||||
.mockRejectedValueOnce(new Error('helcim 503'))
|
||||
.mockRejectedValueOnce(new Error('helcim 503'))
|
||||
.mockRejectedValueOnce(new Error('helcim 503'))
|
||||
.mockResolvedValueOnce([{ id: 'tx3', status: 'paid', amount: 7 }])
|
||||
// Keyed by customerCode so it works regardless of call order (chunked Promise.all).
|
||||
listHelcimCustomerTransactions.mockImplementation((customerCode) => {
|
||||
if (customerCode === 'cust-1') return Promise.resolve([{ id: 'tx1', status: 'paid', amount: 5 }])
|
||||
if (customerCode === 'cust-3') return Promise.resolve([{ id: 'tx3', status: 'paid', amount: 7 }])
|
||||
return Promise.reject(new Error('helcim 503'))
|
||||
})
|
||||
upsertPaymentFromHelcim.mockResolvedValue({ created: true, payment: { _id: 'p' } })
|
||||
|
||||
vi.useFakeTimers()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue