ActivityPub-federated video streaming platform using P2P directly in your web browser
Use random port for mock servers in tests
Chocobozzz63da15eb1806
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.tsindex 1b91d141e5..18ea17d78c 100644--- a/server/tests/external-plugins/auto-block-videos.ts+++ b/server/tests/external-plugins/auto-block-videos.ts@@ -40,6 +40,7 @@ describe('Official plugin auto-block videos', function () {let blocklistServer: MockBlocklistlet server1Videos: Video[] = []let server2Videos: Video[] = []+ let port: numberbefore(async function () {this.timeout(60000)@@ -56,7 +57,7 @@ describe('Official plugin auto-block videos', function () {}blocklistServer = new MockBlocklist()- await blocklistServer.initialize()+ port = await blocklistServer.initialize()await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' })await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' })@@ -82,7 +83,7 @@ describe('Official plugin auto-block videos', function () {accessToken: servers[0].accessToken,npmName: 'peertube-plugin-auto-block-videos',settings: {- 'blocklist-urls': 'http://localhost:42100/blocklist',+ 'blocklist-urls': `http://localhost:${port}/blocklist`,'check-seconds-interval': 1}})diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.tsindex 687f56e981..09355d9326 100644--- a/server/tests/external-plugins/auto-mute.ts+++ b/server/tests/external-plugins/auto-mute.ts@@ -31,6 +31,7 @@ describe('Official plugin auto-mute', function () {const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list'let servers: ServerInfo[]let blocklistServer: MockBlocklist+ let port: numberbefore(async function () {this.timeout(30000)@@ -47,7 +48,7 @@ describe('Official plugin auto-mute', function () {}blocklistServer = new MockBlocklist()- await blocklistServer.initialize()+ port = await blocklistServer.initialize()await uploadVideoAndGetId({ server: servers[0], videoName: 'video server 1' })await uploadVideoAndGetId({ server: servers[1], videoName: 'video server 2' })@@ -61,7 +62,7 @@ describe('Official plugin auto-mute', function () {accessToken: servers[0].accessToken,npmName: 'peertube-plugin-auto-mute',settings: {- 'blocklist-urls': 'http://localhost:42100/blocklist',+ 'blocklist-urls': `http://localhost:${port}/blocklist`,'check-seconds-interval': 1}})diff --git a/shared/extra-utils/plugins/mock-blocklist.ts b/shared/extra-utils/plugins/mock-blocklist.tsindex 50e2289f1e..d18f8224ff 100644--- a/shared/extra-utils/plugins/mock-blocklist.ts+++ b/shared/extra-utils/plugins/mock-blocklist.ts@@ -1,5 +1,6 @@import * as express from 'express'import { Server } from 'http'+import { randomInt } from '@shared/core-utils'type BlocklistResponse = {data: {@@ -14,14 +15,15 @@ export class MockBlocklist {private server: Serverinitialize () {- return new Promise<void>(res => {+ return new Promise<number>(res => {const app = express()app.get('/blocklist', (req: express.Request, res: express.Response) => {return res.json(this.body)})- this.server = app.listen(42100, () => res())+ const port = 42201 + randomInt(1, 100)+ this.server = app.listen(port, () => res(port))})}