Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Close mock blocklit server when tests end

Chocobozzz7820a54e5e16
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts
index 3ec03d5587..1b91d141e5 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 bfdbee80ad..8ead34a2bf 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 6fe3dee9f7..07c8c51226 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()
+ }
}