From f6500729850549e632399155d0f3b69822e28b16 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Apr 2021 13:52:27 +0200 Subject: More robust tests --- shared/extra-utils/mock-servers/joinpeertube-versions.ts | 6 ++++-- shared/extra-utils/mock-servers/mock-instances-index.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'shared/extra-utils/mock-servers') diff --git a/shared/extra-utils/mock-servers/joinpeertube-versions.ts b/shared/extra-utils/mock-servers/joinpeertube-versions.ts index d7d5b2c49..5ea432ecf 100644 --- a/shared/extra-utils/mock-servers/joinpeertube-versions.ts +++ b/shared/extra-utils/mock-servers/joinpeertube-versions.ts @@ -1,10 +1,11 @@ import * as express from 'express' +import { randomInt } from '@shared/core-utils' export class MockJoinPeerTubeVersions { private latestVersion: string initialize () { - return new Promise(res => { + return new Promise(res => { const app = express() app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { @@ -21,7 +22,8 @@ export class MockJoinPeerTubeVersions { }) }) - app.listen(42102, () => res()) + const port = 42201 + randomInt(1, 100) + app.listen(port, () => res(port)) }) } diff --git a/shared/extra-utils/mock-servers/mock-instances-index.ts b/shared/extra-utils/mock-servers/mock-instances-index.ts index 2604eda03..c9e33087d 100644 --- a/shared/extra-utils/mock-servers/mock-instances-index.ts +++ b/shared/extra-utils/mock-servers/mock-instances-index.ts @@ -1,10 +1,11 @@ import * as express from 'express' +import { randomInt } from '@shared/core-utils' export class MockInstancesIndex { private readonly indexInstances: { host: string, createdAt: string }[] = [] initialize () { - return new Promise(res => { + return new Promise(res => { const app = express() app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { @@ -28,7 +29,8 @@ export class MockInstancesIndex { }) }) - app.listen(42101, () => res()) + const port = 42101 + randomInt(1, 100) + app.listen(port, () => res(port)) }) } -- cgit v1.2.3