From: Chocobozzz Date: Fri, 26 Jun 2020 12:50:40 +0000 (+0200) Subject: Close mock blocklit server when tests end X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7820a54e5e168195e58209a4051dd5ecbbec93cf;p=oweals%2Fpeertube.git Close mock blocklit server when tests end --- diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts index 3ec03d558..1b91d141e 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts @@ -185,6 +185,8 @@ describe('Official plugin auto-block videos', function () { }) after(async function () { + await blocklistServer.terminate() + await cleanupTests(servers) }) }) diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index bfdbee80a..8ead34a2b 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts @@ -238,6 +238,8 @@ describe('Official plugin auto-mute', function () { }) after(async function () { + await blocklistServer.terminate() + await cleanupTests(servers) }) }) diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.ts index 6fe3dee9f..07c8c5122 100644 --- a/shared/extra-utils/plugins/mock-blocklist.ts +++ b/shared/extra-utils/plugins/mock-blocklist.ts @@ -1,4 +1,5 @@ import * as express from 'express' +import { Server } from 'http' type BlocklistResponse = { data: { @@ -10,6 +11,7 @@ type BlocklistResponse = { export class MockBlocklist { private body: BlocklistResponse + private server: Server initialize () { return new Promise(res => { @@ -19,11 +21,15 @@ export class MockBlocklist { return res.json(this.body) }) - app.listen(42100, () => res()) + this.server = app.listen(42100, () => res()) }) } replace (body: BlocklistResponse) { this.body = body } + + terminate () { + if (this.server) this.server.close() + } }