diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-26 14:50:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-06-26 14:51:01 +0200 |
commit | 7820a54e5e168195e58209a4051dd5ecbbec93cf (patch) | |
tree | beb0d7a0181424442775639851f4d9d7a8afcb79 | |
parent | 84f6e32c7be4098c08e8735825ce1bcb44e43193 (diff) | |
download | PeerTube-7820a54e5e168195e58209a4051dd5ecbbec93cf.tar.gz PeerTube-7820a54e5e168195e58209a4051dd5ecbbec93cf.tar.zst PeerTube-7820a54e5e168195e58209a4051dd5ecbbec93cf.zip |
Close mock blocklit server when tests end
-rw-r--r-- | server/tests/external-plugins/auto-block-videos.ts | 2 | ||||
-rw-r--r-- | server/tests/external-plugins/auto-mute.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/plugins/mock-blocklist.ts | 8 |
3 files changed, 11 insertions, 1 deletions
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 () { | |||
185 | }) | 185 | }) |
186 | 186 | ||
187 | after(async function () { | 187 | after(async function () { |
188 | await blocklistServer.terminate() | ||
189 | |||
188 | await cleanupTests(servers) | 190 | await cleanupTests(servers) |
189 | }) | 191 | }) |
190 | }) | 192 | }) |
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 () { | |||
238 | }) | 238 | }) |
239 | 239 | ||
240 | after(async function () { | 240 | after(async function () { |
241 | await blocklistServer.terminate() | ||
242 | |||
241 | await cleanupTests(servers) | 243 | await cleanupTests(servers) |
242 | }) | 244 | }) |
243 | }) | 245 | }) |
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 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { Server } from 'http' | ||
2 | 3 | ||
3 | type BlocklistResponse = { | 4 | type BlocklistResponse = { |
4 | data: { | 5 | data: { |
@@ -10,6 +11,7 @@ type BlocklistResponse = { | |||
10 | 11 | ||
11 | export class MockBlocklist { | 12 | export class MockBlocklist { |
12 | private body: BlocklistResponse | 13 | private body: BlocklistResponse |
14 | private server: Server | ||
13 | 15 | ||
14 | initialize () { | 16 | initialize () { |
15 | return new Promise(res => { | 17 | return new Promise(res => { |
@@ -19,11 +21,15 @@ export class MockBlocklist { | |||
19 | return res.json(this.body) | 21 | return res.json(this.body) |
20 | }) | 22 | }) |
21 | 23 | ||
22 | app.listen(42100, () => res()) | 24 | this.server = app.listen(42100, () => res()) |
23 | }) | 25 | }) |
24 | } | 26 | } |
25 | 27 | ||
26 | replace (body: BlocklistResponse) { | 28 | replace (body: BlocklistResponse) { |
27 | this.body = body | 29 | this.body = body |
28 | } | 30 | } |
31 | |||
32 | terminate () { | ||
33 | if (this.server) this.server.close() | ||
34 | } | ||
29 | } | 35 | } |