X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fhelpers%2Frequest.ts;h=a85d80b88cf18acc6f5b8404e17f37286ed7748c;hb=9e5cf66be7ad897e106f283bee73a165c72e74de;hp=c9a2eb8310e1e5e557b513cd09e78938ba872b15;hpb=0305db28c98fd6cf43a3c50ba92c76215e99d512;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/helpers/request.ts b/server/tests/helpers/request.ts index c9a2eb831..a85d80b88 100644 --- a/server/tests/helpers/request.ts +++ b/server/tests/helpers/request.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' import { expect } from 'chai' import { pathExists, remove } from 'fs-extra' import { join } from 'path' -import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils' +import { root, wait } from '@shared/core-utils' import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' +import { FIXTURE_URLS, Mock429 } from '../shared' describe('Request helpers', function () { const destPath1 = join(root(), 'test-output-1.txt') @@ -34,6 +34,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 })