aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/mock-servers/mock-proxy.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-22 14:31:38 +0200
committerChocobozzz <me@florianbigard.com>2021-10-22 14:31:38 +0200
commitd1bfbdeb203b0e4f37e9468861c690171156ee29 (patch)
tree2a6051ef212b964eb2ded1021a625acd0ba32053 /shared/extra-utils/mock-servers/mock-proxy.ts
parent5480933b7f088bf099b25fb467faace814f0da58 (diff)
downloadPeerTube-d1bfbdeb203b0e4f37e9468861c690171156ee29.tar.gz
PeerTube-d1bfbdeb203b0e4f37e9468861c690171156ee29.tar.zst
PeerTube-d1bfbdeb203b0e4f37e9468861c690171156ee29.zip
Random listen for mocked servers
Diffstat (limited to 'shared/extra-utils/mock-servers/mock-proxy.ts')
-rw-r--r--shared/extra-utils/mock-servers/mock-proxy.ts7
1 files changed, 2 insertions, 5 deletions
diff --git a/shared/extra-utils/mock-servers/mock-proxy.ts b/shared/extra-utils/mock-servers/mock-proxy.ts
index 8583250f3..75ac79055 100644
--- a/shared/extra-utils/mock-servers/mock-proxy.ts
+++ b/shared/extra-utils/mock-servers/mock-proxy.ts
@@ -1,18 +1,15 @@
1 1
2import { createServer, Server } from 'http' 2import { createServer, Server } from 'http'
3import proxy from 'proxy' 3import proxy from 'proxy'
4import { randomInt } from '@shared/core-utils' 4import { getPort, terminateServer } from './utils'
5import { terminateServer } from './utils'
6 5
7class MockProxy { 6class MockProxy {
8 private server: Server 7 private server: Server
9 8
10 initialize () { 9 initialize () {
11 return new Promise<number>(res => { 10 return new Promise<number>(res => {
12 const port = 46000 + randomInt(1, 1000)
13
14 this.server = proxy(createServer()) 11 this.server = proxy(createServer())
15 this.server.listen(port, () => res(port)) 12 this.server.listen(0, () => res(getPort(this.server)))
16 }) 13 })
17 } 14 }
18 15