diff options
Diffstat (limited to 'server/tests/helpers/request.ts')
-rw-r--r-- | server/tests/helpers/request.ts | 15 |
1 files changed, 15 insertions, 0 deletions
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' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists, remove } from 'fs-extra' | 5 | import { pathExists, remove } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { Mock429 } from '@shared/extra-utils/mock-servers/mock-429' | ||
7 | import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils' | 8 | import { FIXTURE_URLS, root, wait } from '../../../shared/extra-utils' |
8 | import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' | 9 | import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' |
9 | 10 | ||
@@ -34,6 +35,20 @@ describe('Request helpers', function () { | |||
34 | throw new Error('No error thrown by do request and save to file') | 35 | throw new Error('No error thrown by do request and save to file') |
35 | }) | 36 | }) |
36 | 37 | ||
38 | it('Should correctly retry on 429 error', async function () { | ||
39 | this.timeout(25000) | ||
40 | |||
41 | const mock = new Mock429() | ||
42 | const port = await mock.initialize() | ||
43 | |||
44 | const before = new Date().getTime() | ||
45 | await doRequest('http://localhost:' + port) | ||
46 | |||
47 | expect(new Date().getTime() - before).to.be.greaterThan(2000) | ||
48 | |||
49 | await mock.terminate() | ||
50 | }) | ||
51 | |||
37 | it('Should succeed if the file is below the limit', async function () { | 52 | it('Should succeed if the file is below the limit', async function () { |
38 | await doRequest(FIXTURE_URLS.file4K, { bodyKBLimit: 5 }) | 53 | await doRequest(FIXTURE_URLS.file4K, { bodyKBLimit: 5 }) |
39 | await doRequestAndSaveToFile(FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 }) | 54 | await doRequestAndSaveToFile(FIXTURE_URLS.file4K, destPath2, { bodyKBLimit: 5 }) |