diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-15 13:52:27 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-15 13:52:27 +0200 |
commit | f6500729850549e632399155d0f3b69822e28b16 (patch) | |
tree | 7ca40188e38b0281f538c4cddf79ea633745cc4a /shared/extra-utils | |
parent | f1ac63488c0050fec1c4d713d74db4f4ea944395 (diff) | |
download | PeerTube-f6500729850549e632399155d0f3b69822e28b16.tar.gz PeerTube-f6500729850549e632399155d0f3b69822e28b16.tar.zst PeerTube-f6500729850549e632399155d0f3b69822e28b16.zip |
More robust tests
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/mock-servers/joinpeertube-versions.ts | 6 | ||||
-rw-r--r-- | shared/extra-utils/mock-servers/mock-instances-index.ts | 6 |
2 files changed, 8 insertions, 4 deletions
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { randomInt } from '@shared/core-utils' | ||
2 | 3 | ||
3 | export class MockJoinPeerTubeVersions { | 4 | export class MockJoinPeerTubeVersions { |
4 | private latestVersion: string | 5 | private latestVersion: string |
5 | 6 | ||
6 | initialize () { | 7 | initialize () { |
7 | return new Promise<void>(res => { | 8 | return new Promise<number>(res => { |
8 | const app = express() | 9 | const app = express() |
9 | 10 | ||
10 | app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { | 11 | app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { |
@@ -21,7 +22,8 @@ export class MockJoinPeerTubeVersions { | |||
21 | }) | 22 | }) |
22 | }) | 23 | }) |
23 | 24 | ||
24 | app.listen(42102, () => res()) | 25 | const port = 42201 + randomInt(1, 100) |
26 | app.listen(port, () => res(port)) | ||
25 | }) | 27 | }) |
26 | } | 28 | } |
27 | 29 | ||
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { randomInt } from '@shared/core-utils' | ||
2 | 3 | ||
3 | export class MockInstancesIndex { | 4 | export class MockInstancesIndex { |
4 | private readonly indexInstances: { host: string, createdAt: string }[] = [] | 5 | private readonly indexInstances: { host: string, createdAt: string }[] = [] |
5 | 6 | ||
6 | initialize () { | 7 | initialize () { |
7 | return new Promise<void>(res => { | 8 | return new Promise<number>(res => { |
8 | const app = express() | 9 | const app = express() |
9 | 10 | ||
10 | app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { | 11 | app.use('/', (req: express.Request, res: express.Response, next: express.NextFunction) => { |
@@ -28,7 +29,8 @@ export class MockInstancesIndex { | |||
28 | }) | 29 | }) |
29 | }) | 30 | }) |
30 | 31 | ||
31 | app.listen(42101, () => res()) | 32 | const port = 42101 + randomInt(1, 100) |
33 | app.listen(port, () => res(port)) | ||
32 | }) | 34 | }) |
33 | } | 35 | } |
34 | 36 | ||