From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/plugins/action-hooks.ts | 11 +++++------ server/tests/plugins/external-auth.ts | 10 +++++----- server/tests/plugins/filter-hooks.ts | 8 ++++---- server/tests/plugins/html-injection.ts | 8 ++++---- server/tests/plugins/id-and-pass-auth.ts | 6 +++--- server/tests/plugins/plugin-helpers.ts | 10 +++++----- server/tests/plugins/plugin-router.ts | 8 ++++---- server/tests/plugins/plugin-storage.ts | 13 ++++++++++--- server/tests/plugins/plugin-transcoding.ts | 12 ++++++------ server/tests/plugins/plugin-unloading.ts | 13 ++++++++++--- server/tests/plugins/translations.ts | 7 +++---- server/tests/plugins/video-constants.ts | 6 +++--- 12 files changed, 62 insertions(+), 50 deletions(-) (limited to 'server/tests/plugins') diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts index 12d5c23c5..b96de4e90 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/server/tests/plugins/action-hooks.ts @@ -3,18 +3,17 @@ import 'mocha' import { cleanupTests, - flushAndRunMultipleServers, + createMultipleServers, killallServers, + PeerTubeServer, PluginsCommand, - reRunServer, - ServerInfo, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils' import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' describe('Test plugin action hooks', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let videoUUID: string let threadId: number @@ -25,7 +24,7 @@ describe('Test plugin action hooks', function () { before(async function () { this.timeout(30000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) @@ -33,7 +32,7 @@ describe('Test plugin action hooks', function () { await killallServers([ servers[0] ]) - await reRunServer(servers[0], { + await servers[0].run({ live: { enabled: true } diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index 48f942f7f..c0834a14c 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts @@ -6,16 +6,16 @@ import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, decodeQueryString, - flushAndRunServer, + createSingleServer, PluginsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' import { UserRole } from '@shared/models' async function loginExternal (options: { - server: ServerInfo + server: PeerTubeServer npmName: string authName: string username: string @@ -46,7 +46,7 @@ async function loginExternal (options: { } describe('Test external auth plugins', function () { - let server: ServerInfo + let server: PeerTubeServer let cyanAccessToken: string let cyanRefreshToken: string @@ -59,7 +59,7 @@ describe('Test external auth plugins', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) for (const suffix of [ 'one', 'two', 'three' ]) { diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 18479dcf5..5d94303a9 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts @@ -6,11 +6,11 @@ import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, ImportsCommand, makeRawRequest, PluginsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, waitJobs @@ -20,14 +20,14 @@ import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, Vi const expect = chai.expect describe('Test plugin filter hooks', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let videoUUID: string let threadId: number before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) await doubleFollow(servers[0], servers[1]) diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 0cb89f511..2902c39b7 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts @@ -4,23 +4,23 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, makeHTMLRequest, PluginsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers } from '../../../shared/extra-utils' const expect = chai.expect describe('Test plugins HTML injection', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null let command: PluginsCommand before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) command = server.plugins diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 203996af8..981bcad91 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts @@ -3,11 +3,11 @@ import 'mocha' import { expect } from 'chai' import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, PluginsCommand, ServerInfo, setAccessTokensToServers, wait } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' import { UserRole } from '@shared/models' describe('Test id and pass auth plugins', function () { - let server: ServerInfo + let server: PeerTubeServer let crashAccessToken: string let crashRefreshToken: string @@ -18,7 +18,7 @@ describe('Test id and pass auth plugins', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) for (const suffix of [ 'one', 'two', 'three' ]) { diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index cf16aaa9d..1d87b84ae 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -7,16 +7,16 @@ import { checkVideoFilesWereRemoved, cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, makeGetRequest, makePostBodyRequest, PluginsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' -function postCommand (server: ServerInfo, command: string, bodyArg?: object) { +function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { const body = { command } if (bodyArg) Object.assign(body, bodyArg) @@ -29,12 +29,12 @@ function postCommand (server: ServerInfo, command: string, bodyArg?: object) { } describe('Test plugin helpers', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await doubleFollow(servers[0], servers[1]) diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index 1c53dd80c..dec8ca4bb 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts @@ -5,16 +5,16 @@ import { expect } from 'chai' import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, - flushAndRunServer, + createSingleServer, makeGetRequest, makePostBodyRequest, PluginsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' describe('Test plugin helpers', function () { - let server: ServerInfo + let server: PeerTubeServer const basePaths = [ '/plugins/test-five/router/', '/plugins/test-five/0.0.1/router/' @@ -23,7 +23,7 @@ describe('Test plugin helpers', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') }) diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts index 30e231439..5745914a5 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/server/tests/plugins/plugin-storage.ts @@ -5,15 +5,22 @@ import { expect } from 'chai' import { pathExists, readdir, readFile } from 'fs-extra' import { join } from 'path' import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + PluginsCommand, + setAccessTokensToServers +} from '@shared/extra-utils' describe('Test plugin storage', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') }) diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index 3a03065b0..3c54d3796 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts @@ -6,9 +6,9 @@ import { join } from 'path' import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' import { cleanupTests, - flushAndRunServer, + createSingleServer, PluginsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, testFfmpegStreamError, @@ -16,7 +16,7 @@ import { } from '@shared/extra-utils' import { VideoPrivacy } from '@shared/models' -async function createLiveWrapper (server: ServerInfo) { +async function createLiveWrapper (server: PeerTubeServer) { const liveAttributes = { name: 'live video', channelId: server.store.channel.id, @@ -28,7 +28,7 @@ async function createLiveWrapper (server: ServerInfo) { return uuid } -function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) { +function updateConf (server: PeerTubeServer, vodProfile: string, liveProfile: string) { return server.config.updateCustomSubConfig({ newConfig: { transcoding: { @@ -64,12 +64,12 @@ function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string } describe('Test transcoding plugins', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(60000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 26a27abca..6c405b7f5 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts @@ -3,17 +3,24 @@ import 'mocha' import { expect } from 'chai' import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { + cleanupTests, + createSingleServer, + makeGetRequest, + PeerTubeServer, + PluginsCommand, + setAccessTokensToServers +} from '@shared/extra-utils' describe('Test plugins module unloading', function () { - let server: ServerInfo = null + let server: PeerTubeServer = null const requestPath = '/plugins/test-unloading/router/get' let value: string = null before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts index d8d878026..8b25c6b75 100644 --- a/server/tests/plugins/translations.ts +++ b/server/tests/plugins/translations.ts @@ -2,19 +2,18 @@ import 'mocha' import * as chai from 'chai' -import { PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' +import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils' const expect = chai.expect describe('Test plugin translations', function () { - let server: ServerInfo + let server: PeerTubeServer let command: PluginsCommand before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) command = server.plugins diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index facc6bbc1..953916e8e 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts @@ -3,18 +3,18 @@ import 'mocha' import * as chai from 'chai' import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect describe('Test plugin altering video constants', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') }) -- cgit v1.2.3