From 3455c2656e257ae3d9b4169af58b6889d9904148 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 16 Nov 2021 11:17:52 +0100 Subject: Test and log request retries --- server/tests/helpers/request.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'server/tests/helpers') diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts index c9a2eb831..6edbf2a76 100644 --- a/server/tests/helpers/request.ts +++ b/server/tests/helpers/request.ts @@ -4,6 +4,7 @@ import 'mocha' import { expect } from 'chai' import { pathExists, remove } from 'fs-extra' import { join } from 'path' +import { Mock429 } from '@shared/extra-utils/mock-servers/mock-429' import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils' import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' @@ -34,6 +35,20 @@ describe('Request helpers', function () { throw new Error('No error thrown by do request and save to file') }) + it('Should correctly retry on 429 error', async function () { + this.timeout(25000) + + const mock = new Mock429() + const port = await mock.initialize() + + const before = new Date().getTime() + await doRequest('http://localhost:' + port) + + expect(new Date().getTime() - before).to.be.greaterThan(2000) + + await mock.terminate() + }) + it('Should succeed if the file is below the limit', async function () { await doRequest(FIXTURE_URLS.file4K, { bodyKBLimit: 5 }) await doRequestAndSaveToFile(FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 }) -- cgit v1.2.3