diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-14 11:35:43 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-14 11:35:43 +0200 |
commit | cf0c8ee588e37809d85ec1deec1e4fdfa0f122a5 (patch) | |
tree | 1692868027592d2a300988643fdd96e5fdfe2091 /shared/extra-utils/mock-servers | |
parent | e1a570abff3ebf375433e58e7362d56bd32d4cd8 (diff) | |
download | PeerTube-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.ts | 10 |
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 @@ | |||
1 | import express from 'express' | 1 | import express from 'express' |
2 | import { Server } from 'http' | ||
2 | import { randomInt } from '@shared/core-utils' | 3 | import { randomInt } from '@shared/core-utils' |
4 | import { terminateServer } from './utils' | ||
3 | 5 | ||
4 | export class MockInstancesIndex { | 6 | export 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 | } |