From cf0c8ee588e37809d85ec1deec1e4fdfa0f122a5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 14 Oct 2021 11:35:43 +0200 Subject: Fix admin edition disabling feature --- shared/extra-utils/mock-servers/mock-instances-index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'shared/extra-utils') 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 @@ import express from 'express' +import { Server } from 'http' import { randomInt } from '@shared/core-utils' +import { terminateServer } from './utils' export class MockInstancesIndex { + private server: Server + private readonly indexInstances: { host: string, createdAt: string }[] = [] initialize () { @@ -30,11 +34,15 @@ export class MockInstancesIndex { }) const port = 42000 + randomInt(1, 1000) - app.listen(port, () => res(port)) + this.server = app.listen(port, () => res(port)) }) } addInstance (host: string) { this.indexInstances.push({ host, createdAt: new Date().toISOString() }) } + + terminate () { + return terminateServer(this.server) + } } -- cgit v1.2.3