aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/mock-servers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-14 11:35:43 +0200
committerChocobozzz <me@florianbigard.com>2021-10-14 11:35:43 +0200
commitcf0c8ee588e37809d85ec1deec1e4fdfa0f122a5 (patch)
tree1692868027592d2a300988643fdd96e5fdfe2091 /shared/extra-utils/mock-servers
parente1a570abff3ebf375433e58e7362d56bd32d4cd8 (diff)
downloadPeerTube-cf0c8ee588e37809d85ec1deec1e4fdfa0f122a5.tar.gz
PeerTube-cf0c8ee588e37809d85ec1deec1e4fdfa0f122a5.tar.zst
PeerTube-cf0c8ee588e37809d85ec1deec1e4fdfa0f122a5.zip
Fix admin edition disabling feature
Diffstat (limited to 'shared/extra-utils/mock-servers')
-rw-r--r--shared/extra-utils/mock-servers/mock-instances-index.ts10
1 files changed, 9 insertions, 1 deletions
diff --git a/shared/extra-utils/mock-servers/mock-instances-index.ts b/shared/extra-utils/mock-servers/mock-instances-index.ts
index 5baec00de..43c2e9f6e 100644
--- a/shared/extra-utils/mock-servers/mock-instances-index.ts
+++ b/shared/extra-utils/mock-servers/mock-instances-index.ts
@@ -1,7 +1,11 @@
1import express from 'express' 1import express from 'express'
2import { Server } from 'http'
2import { randomInt } from '@shared/core-utils' 3import { randomInt } from '@shared/core-utils'
4import { terminateServer } from './utils'
3 5
4export class MockInstancesIndex { 6export class MockInstancesIndex {
7 private server: Server
8
5 private readonly indexInstances: { host: string, createdAt: string }[] = [] 9 private readonly indexInstances: { host: string, createdAt: string }[] = []
6 10
7 initialize () { 11 initialize () {
@@ -30,11 +34,15 @@ export class MockInstancesIndex {
30 }) 34 })
31 35
32 const port = 42000 + randomInt(1, 1000) 36 const port = 42000 + randomInt(1, 1000)
33 app.listen(port, () => res(port)) 37 this.server = app.listen(port, () => res(port))
34 }) 38 })
35 } 39 }
36 40
37 addInstance (host: string) { 41 addInstance (host: string) {
38 this.indexInstances.push({ host, createdAt: new Date().toISOString() }) 42 this.indexInstances.push({ host, createdAt: new Date().toISOString() })
39 } 43 }
44
45 terminate () {
46 return terminateServer(this.server)
47 }
40} 48}