Skip to content

Commit e18626b

Browse files
committed
tets: changed exp backoff nock scope to mimick all retryable codes in sequence
1 parent 0a7f0c6 commit e18626b

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

nodes/Apify/__tests__/Apify.node.spec.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -512,25 +512,24 @@ describe('Apify Node', () => {
512512

513513
describe('api calls', () => {
514514
it('should retry the specified number of times with exponential delays', async () => {
515-
const retryAbleCodes = [429, 500];
516515
const storeId = 'yTfMu13hDFe9bRjx6';
517516
const recordKey = 'INPUT';
518517

519-
for (const code of retryAbleCodes) {
520-
const scope = nock('https://api.apify.com')
521-
.get(`/v2/key-value-stores/${storeId}/records/${recordKey}`)
522-
.reply(code)
523-
.get(`/v2/key-value-stores/${storeId}/records/${recordKey}`)
524-
.reply(200);
525-
526-
const getKeyValueStoreRecordWorkflow = require('./workflows/key-value-stores/get-key-value-store-record.workflow.json');
527-
await executeWorkflow({
528-
credentialsHelper,
529-
workflow: getKeyValueStoreRecordWorkflow,
530-
});
518+
const scope = nock('https://api.apify.com')
519+
.get(`/v2/key-value-stores/${storeId}/records/${recordKey}`)
520+
.reply(500)
521+
.get(`/v2/key-value-stores/${storeId}/records/${recordKey}`)
522+
.reply(429)
523+
.get(`/v2/key-value-stores/${storeId}/records/${recordKey}`)
524+
.reply(200);
525+
526+
const getKeyValueStoreRecordWorkflow = require('./workflows/key-value-stores/get-key-value-store-record.workflow.json');
527+
await executeWorkflow({
528+
credentialsHelper,
529+
workflow: getKeyValueStoreRecordWorkflow,
530+
});
531531

532-
expect(scope.isDone()).toBe(true);
533-
}
532+
expect(scope.isDone()).toBe(true);
534533
});
535534
});
536535
});

0 commit comments

Comments
 (0)