aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/plugins
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-03 09:06:51 +0200
committerChocobozzz <me@florianbigard.com>2021-06-03 09:06:51 +0200
commit63da15eb18065ef6c419f073c95fec6ef5541652 (patch)
treea95855514d4d7ed8dd1bba0934d8640902ff330e /shared/extra-utils/plugins
parent38c5c166f4204292d58f61658a063408a9e7b78c (diff)
downloadPeerTube-63da15eb18065ef6c419f073c95fec6ef5541652.tar.gz
PeerTube-63da15eb18065ef6c419f073c95fec6ef5541652.tar.zst
PeerTube-63da15eb18065ef6c419f073c95fec6ef5541652.zip
Use random port for mock servers in tests
Diffstat (limited to 'shared/extra-utils/plugins')
-rw-r--r--shared/extra-utils/plugins/mock-blocklist.ts6
1 files changed, 4 insertions, 2 deletions
diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts
index 50e2289f1..d18f8224f 100644
--- a/shared/extra-utils/plugins/mock-blocklist.ts
+++ b/shared/extra-utils/plugins/mock-blocklist.ts
@@ -1,5 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { Server } from 'http' 2import { Server } from 'http'
3import { randomInt } from '@shared/core-utils'
3 4
4type BlocklistResponse = { 5type BlocklistResponse = {
5 data: { 6 data: {
@@ -14,14 +15,15 @@ export class MockBlocklist {
14 private server: Server 15 private server: Server
15 16
16 initialize () { 17 initialize () {
17 return new Promise<void>(res => { 18 return new Promise<number>(res => {
18 const app = express() 19 const app = express()
19 20
20 app.get('/blocklist', (req: express.Request, res: express.Response) => { 21 app.get('/blocklist', (req: express.Request, res: express.Response) => {
21 return res.json(this.body) 22 return res.json(this.body)
22 }) 23 })
23 24
24 this.server = app.listen(42100, () => res()) 25 const port = 42201 + randomInt(1, 100)
26 this.server = app.listen(port, () => res(port))
25 }) 27 })
26 } 28 }
27 29