From 329619b3453479f76c049816b7403b86e9d45cb5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 5 Jul 2021 16:37:50 +0200 Subject: Introduce CLI command --- server/tests/cli/create-import-video-file-job.ts | 14 ++-- server/tests/cli/create-transcoding-job.ts | 23 ++----- server/tests/cli/optimize-old-videos.ts | 6 +- server/tests/cli/peertube.ts | 82 ++++++++---------------- server/tests/cli/plugins.ts | 13 ++-- server/tests/cli/print-transcode-command.ts | 7 +- server/tests/cli/prune-storage.ts | 7 +- server/tests/cli/regenerate-thumbnails.ts | 5 +- server/tests/cli/reset-password.ts | 10 ++- server/tests/cli/update-host.ts | 14 ++-- 10 files changed, 62 insertions(+), 119 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 49758ff56..8a23a94de 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -6,9 +6,7 @@ import { VideoFile } from '@shared/models/videos/video-file.model' import { cleanupTests, doubleFollow, - execCLI, flushAndRunMultipleServers, - getEnvCli, getVideo, getVideosList, ServerInfo, @@ -57,8 +55,8 @@ describe('Test create import video jobs', function () { }) it('Should run a import job on video 1 with a lower resolution', async function () { - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`) + const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm` + await servers[0].cliCommand.execWithEnv(command) await waitJobs(servers) @@ -77,8 +75,8 @@ describe('Test create import video jobs', function () { }) it('Should run a import job on video 2 with the same resolution and a different extension', async function () { - const env = getEnvCli(servers[1]) - await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) + const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv` + await servers[1].cliCommand.execWithEnv(command) await waitJobs(servers) @@ -99,8 +97,8 @@ describe('Test create import video jobs', function () { }) it('Should run a import job on video 2 with the same resolution and the same extension', async function () { - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`) + const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm` + await servers[0].cliCommand.execWithEnv(command) await waitJobs(servers) diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index 5bc1687cd..be46dec25 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -2,13 +2,10 @@ import 'mocha' import * as chai from 'chai' -import { VideoDetails } from '../../../shared/models/videos' import { cleanupTests, doubleFollow, - execCLI, flushAndRunMultipleServers, - getEnvCli, getVideo, getVideosList, ServerInfo, @@ -17,6 +14,7 @@ import { uploadVideo } from '../../../shared/extra-utils' import { waitJobs } from '../../../shared/extra-utils/server/jobs' +import { VideoDetails } from '../../../shared/models/videos' const expect = chai.expect @@ -81,9 +79,7 @@ describe('Test create transcoding jobs', function () { it('Should run a transcoding job on video 2', async function () { this.timeout(60000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[1]}`) - + await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`) await waitJobs(servers) for (const server of servers) { @@ -123,8 +119,7 @@ describe('Test create transcoding jobs', function () { it('Should run a transcoding job on video 1 with resolution', async function () { this.timeout(60000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`) + await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`) await waitJobs(servers) @@ -147,8 +142,7 @@ describe('Test create transcoding jobs', function () { it('Should generate an HLS resolution', async function () { this.timeout(120000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) + await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) await waitJobs(servers) @@ -168,8 +162,7 @@ describe('Test create transcoding jobs', function () { it('Should not duplicate an HLS resolution', async function () { this.timeout(120000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) + await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) await waitJobs(servers) @@ -186,8 +179,7 @@ describe('Test create transcoding jobs', function () { it('Should generate all HLS resolutions', async function () { this.timeout(120000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`) + await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`) await waitJobs(servers) @@ -209,8 +201,7 @@ describe('Test create transcoding jobs', function () { config.transcoding.hls.enabled = true await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-transcoding-job -- -v ${videosUUID[4]}`) + await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`) await waitJobs(servers) diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index 91a1c9cc4..bd15012fe 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -7,10 +7,8 @@ import { buildServerDirectory, cleanupTests, doubleFollow, - execCLI, flushAndRunMultipleServers, generateHighBitrateVideo, - getEnvCli, getVideo, getVideosList, ServerInfo, @@ -73,9 +71,7 @@ describe('Test optimize old videos', function () { it('Should run optimize script', async function () { this.timeout(200000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run optimize-old-videos`) - + await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos') await waitJobs(servers) for (const server of servers) { diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index fcf7e2e2e..0a4f54ffa 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -8,11 +8,10 @@ import { areHttpImportTestsDisabled, buildAbsoluteFixturePath, cleanupTests, + CLICommand, createUser, doubleFollow, - execCLI, flushAndRunServer, - getEnvCli, getLocalIdByUUID, getVideo, getVideosList, @@ -30,6 +29,8 @@ describe('Test CLI wrapper', function () { let server: ServerInfo let userAccessToken: string + let cliCommand: CLICommand + const cmd = 'node ./dist/server/tools/peertube.js' before(async function () { @@ -46,6 +47,8 @@ describe('Test CLI wrapper', function () { const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } await addVideoChannel(server.url, userAccessToken, args) } + + cliCommand = server.cliCommand }) describe('Authentication and instance selection', function () { @@ -53,46 +56,38 @@ describe('Test CLI wrapper', function () { it('Should display no selected instance', async function () { this.timeout(60000) - const env = getEnvCli(server) - const stdout = await execCLI(`${env} ${cmd} --help`) - + const stdout = await cliCommand.execWithEnv(`${cmd} --help`) expect(stdout).to.contain('no instance selected') }) it('Should add a user', async function () { this.timeout(60000) - const env = getEnvCli(server) - await execCLI(`${env} ${cmd} auth add -u ${server.url} -U user_1 -p super_password`) + await cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U user_1 -p super_password`) }) it('Should not fail to add a user if there is a slash at the end of the instance URL', async function () { this.timeout(60000) - const env = getEnvCli(server) - let fullServerURL - fullServerURL = server.url + '/' - await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) + let fullServerURL = server.url + '/' + + await cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) fullServerURL = server.url + '/asdfasdf' - await execCLI(`${env} ${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) + await cliCommand.execWithEnv(`${cmd} auth add -u ${fullServerURL} -U user_1 -p super_password`) }) it('Should default to this user', async function () { this.timeout(60000) - const env = getEnvCli(server) - const stdout = await execCLI(`${env} ${cmd} --help`) - + const stdout = await cliCommand.execWithEnv(`${cmd} --help`) expect(stdout).to.contain(`instance ${server.url} selected`) }) it('Should remember the user', async function () { this.timeout(60000) - const env = getEnvCli(server) - const stdout = await execCLI(`${env} ${cmd} auth list`) - + const stdout = await cliCommand.execWithEnv(`${cmd} auth list`) expect(stdout).to.contain(server.url) }) }) @@ -102,13 +97,10 @@ describe('Test CLI wrapper', function () { it('Should upload a video', async function () { this.timeout(60000) - const env = getEnvCli(server) - const fixture = buildAbsoluteFixturePath('60fps_720p_small.mp4') - const params = `-f ${fixture} --video-name 'test upload' --channel-name user_channel --support 'support_text'` - await execCLI(`${env} ${cmd} upload ${params}`) + await cliCommand.execWithEnv(`${cmd} upload ${params}`) }) it('Should have the video uploaded', async function () { @@ -130,11 +122,8 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const env = getEnvCli(server) - const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` - - await execCLI(`${env} ${cmd} import ${params}`) + await cliCommand.execWithEnv(`${cmd} import ${params}`) }) it('Should have imported the video', async function () { @@ -166,11 +155,8 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const env = getEnvCli(server) - const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` - - await execCLI(`${env} ${cmd} import ${params}`) + await cliCommand.execWithEnv(`${cmd} import ${params}`) await waitJobs([ server ]) @@ -194,18 +180,14 @@ describe('Test CLI wrapper', function () { describe('Admin auth', function () { it('Should remove the auth user', async function () { - const env = getEnvCli(server) - - await execCLI(`${env} ${cmd} auth del ${server.url}`) - - const stdout = await execCLI(`${env} ${cmd} --help`) + await cliCommand.execWithEnv(`${cmd} auth del ${server.url}`) + const stdout = await cliCommand.execWithEnv(`${cmd} --help`) expect(stdout).to.contain('no instance selected') }) it('Should add the admin user', async function () { - const env = getEnvCli(server) - await execCLI(`${env} ${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`) + await cliCommand.execWithEnv(`${cmd} auth add -u ${server.url} -U root -p test${server.internalServerNumber}`) }) }) @@ -214,8 +196,7 @@ describe('Test CLI wrapper', function () { it('Should install a plugin', async function () { this.timeout(60000) - const env = getEnvCli(server) - await execCLI(`${env} ${cmd} plugins install --npm-name peertube-plugin-hello-world`) + await cliCommand.execWithEnv(`${cmd} plugins install --npm-name peertube-plugin-hello-world`) }) it('Should have registered settings', async function () { @@ -223,15 +204,13 @@ describe('Test CLI wrapper', function () { }) it('Should list installed plugins', async function () { - const env = getEnvCli(server) - const res = await execCLI(`${env} ${cmd} plugins list`) + const res = await cliCommand.execWithEnv(`${cmd} plugins list`) expect(res).to.contain('peertube-plugin-hello-world') }) it('Should uninstall the plugin', async function () { - const env = getEnvCli(server) - const res = await execCLI(`${env} ${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`) + const res = await cliCommand.execWithEnv(`${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`) expect(res).to.not.contain('peertube-plugin-hello-world') }) @@ -262,11 +241,8 @@ describe('Test CLI wrapper', function () { it('Should add a redundancy', async function () { this.timeout(60000) - const env = getEnvCli(server) - const params = `add --video ${video1Server2}` - - await execCLI(`${env} ${cmd} redundancy ${params}`) + await cliCommand.execWithEnv(`${cmd} redundancy ${params}`) await waitJobs(servers) }) @@ -275,10 +251,8 @@ describe('Test CLI wrapper', function () { this.timeout(60000) { - const env = getEnvCli(server) - const params = 'list-my-redundancies' - const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`) + const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`) expect(stdout).to.contain('super video') expect(stdout).to.contain(`localhost:${server.port}`) @@ -288,18 +262,14 @@ describe('Test CLI wrapper', function () { it('Should remove a redundancy', async function () { this.timeout(60000) - const env = getEnvCli(server) - const params = `remove --video ${video1Server2}` - - await execCLI(`${env} ${cmd} redundancy ${params}`) + await cliCommand.execWithEnv(`${cmd} redundancy ${params}`) await waitJobs(servers) { - const env = getEnvCli(server) const params = 'list-my-redundancies' - const stdout = await execCLI(`${env} ${cmd} redundancy ${params}`) + const stdout = await cliCommand.execWithEnv(`${cmd} redundancy ${params}`) expect(stdout).to.not.contain('super video') } diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index 7f19f14b7..efdc20748 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -1,12 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { expect } from 'chai' import { cleanupTests, - execCLI, flushAndRunServer, getConfig, - getEnvCli, getPluginTestPath, killallServers, reRunServer, @@ -14,7 +13,6 @@ import { setAccessTokensToServers } from '../../../shared/extra-utils' import { ServerConfig } from '../../../shared/models/server' -import { expect } from 'chai' describe('Test plugin scripts', function () { let server: ServerInfo @@ -31,15 +29,13 @@ describe('Test plugin scripts', function () { const packagePath = getPluginTestPath() - const env = getEnvCli(server) - await execCLI(`${env} npm run plugin:install -- --plugin-path ${packagePath}`) + await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) }) it('Should install a theme from stateless CLI', async function () { this.timeout(60000) - const env = getEnvCli(server) - await execCLI(`${env} npm run plugin:install -- --npm-name peertube-theme-background-red`) + await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`) }) it('Should have the theme and the plugin registered when we restart peertube', async function () { @@ -63,8 +59,7 @@ describe('Test plugin scripts', function () { it('Should uninstall a plugin from stateless CLI', async function () { this.timeout(60000) - const env = getEnvCli(server) - await execCLI(`${env} npm run plugin:uninstall -- --npm-name peertube-plugin-test`) + await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`) }) it('Should have removed the plugin on another peertube restart', async function () { diff --git a/server/tests/cli/print-transcode-command.ts b/server/tests/cli/print-transcode-command.ts index 2d7255db7..3a7969e68 100644 --- a/server/tests/cli/print-transcode-command.ts +++ b/server/tests/cli/print-transcode-command.ts @@ -2,14 +2,15 @@ import 'mocha' import * as chai from 'chai' -import { execCLI } from '../../../shared/extra-utils' +import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' +import { CLICommand } from '@shared/extra-utils' import { getTargetBitrate, VideoResolution } from '../../../shared/models/videos' import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' -import { getVideoFileBitrate, getVideoFileFPS } from '@server/helpers/ffprobe-utils' const expect = chai.expect describe('Test create transcoding jobs', function () { + it('Should print the correct command for each resolution', async function () { const fixturePath = 'server/tests/fixtures/video_short.webm' const fps = await getVideoFileFPS(fixturePath) @@ -19,7 +20,7 @@ describe('Test create transcoding jobs', function () { VideoResolution.H_720P, VideoResolution.H_1080P ]) { - const command = await execCLI(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) + const command = await CLICommand.exec(`npm run print-transcode-command -- ${fixturePath} -r ${resolution}`) const targetBitrate = Math.min(getTargetBitrate(resolution, fps, VIDEO_TRANSCODING_FPS), bitrate) expect(command).to.includes(`-vf scale=w=-2:h=${resolution}`) diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index a0af09de8..81f91105c 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -9,12 +9,11 @@ import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-code import { buildServerDirectory, cleanupTests, + CLICommand, createVideoPlaylist, doubleFollow, - execCLI, flushAndRunMultipleServers, getAccount, - getEnvCli, killallServers, makeGetRequest, ServerInfo, @@ -193,8 +192,8 @@ describe('Test prune storage scripts', function () { it('Should run prune storage', async function () { this.timeout(30000) - const env = getEnvCli(servers[0]) - await execCLI(`echo y | ${env} npm run prune-storage`) + const env = servers[0].cliCommand.getEnv() + await CLICommand.exec(`echo y | ${env} npm run prune-storage`) }) it('Should have removed files', async function () { diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index 8acb9f263..1b460e9c0 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -7,9 +7,7 @@ import { buildServerDirectory, cleanupTests, doubleFollow, - execCLI, flushAndRunMultipleServers, - getEnvCli, getVideo, makeRawRequest, ServerInfo, @@ -91,8 +89,7 @@ describe('Test regenerate thumbnails script', function () { it('Should regenerate local thumbnails from the CLI', async function () { this.timeout(15000) - const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run regenerate-thumbnails`) + await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`) }) it('Should have generated new thumbnail files', async function () { diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index a84463b33..97a6eae15 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts @@ -1,16 +1,14 @@ import 'mocha' - +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' import { cleanupTests, + CLICommand, createUser, - execCLI, flushAndRunServer, - getEnvCli, login, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' describe('Test reset password scripts', function () { let server: ServerInfo @@ -26,8 +24,8 @@ describe('Test reset password scripts', function () { it('Should change the user password from CLI', async function () { this.timeout(60000) - const env = getEnvCli(server) - await execCLI(`echo coucou | ${env} npm run reset-password -- -u user_1`) + const env = server.cliCommand.getEnv() + await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`) await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200) }) diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 2070f16f5..1b1a76aef 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -2,27 +2,26 @@ import 'mocha' import * as chai from 'chai' -import { VideoDetails } from '../../../shared/models/videos' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' import { addVideoChannel, cleanupTests, createUser, - execCLI, flushAndRunServer, - getEnvCli, getVideo, getVideoChannelsList, getVideosList, killallServers, makeActivityPubGetRequest, - parseTorrentVideo, reRunServer, + parseTorrentVideo, + reRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../shared/extra-utils' +import { waitJobs } from '../../../shared/extra-utils/server/jobs' import { getAccountsList } from '../../../shared/extra-utils/users/accounts' +import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' +import { VideoDetails } from '../../../shared/models/videos' const expect = chai.expect @@ -72,8 +71,7 @@ describe('Test update host scripts', function () { // Run server with standard configuration await reRunServer(server) - const env = getEnvCli(server) - await execCLI(`${env} npm run update-host`) + await server.cliCommand.execWithEnv(`npm run update-host`) }) it('Should have updated videos url', async function () { -- cgit v1.2.3 From ae2abfd3aed3e75d39a316b49b914d187faa7475 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 10:33:49 +0200 Subject: Introduce plugins command --- server/tests/cli/plugins.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index efdc20748..7b8746a5d 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -6,8 +6,8 @@ import { cleanupTests, flushAndRunServer, getConfig, - getPluginTestPath, killallServers, + PluginsCommand, reRunServer, ServerInfo, setAccessTokensToServers @@ -27,7 +27,7 @@ describe('Test plugin scripts', function () { it('Should install a plugin from stateless CLI', async function () { this.timeout(60000) - const packagePath = getPluginTestPath() + const packagePath = PluginsCommand.getPluginTestPath() await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) }) -- cgit v1.2.3 From 65e6e2602c0d5521f3a6740f7469bb92830ecb53 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:51:09 +0200 Subject: Introduce config command --- server/tests/cli/create-transcoding-job.ts | 5 ++--- server/tests/cli/plugins.ts | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index be46dec25..e3211882d 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -10,7 +10,6 @@ import { getVideosList, ServerInfo, setAccessTokensToServers, - updateCustomSubConfig, uploadVideo } from '../../../shared/extra-utils' import { waitJobs } from '../../../shared/extra-utils/server/jobs' @@ -47,7 +46,7 @@ describe('Test create transcoding jobs', function () { servers = await flushAndRunMultipleServers(2) await setAccessTokensToServers(servers) - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) + await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) await doubleFollow(servers[0], servers[1]) @@ -199,7 +198,7 @@ describe('Test create transcoding jobs', function () { this.timeout(120000) config.transcoding.hls.enabled = true - await updateCustomSubConfig(servers[0].url, servers[0].accessToken, config) + await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`) diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index 7b8746a5d..e5efae36b 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -5,14 +5,12 @@ import { expect } from 'chai' import { cleanupTests, flushAndRunServer, - getConfig, killallServers, PluginsCommand, reRunServer, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils' -import { ServerConfig } from '../../../shared/models/server' describe('Test plugin scripts', function () { let server: ServerInfo @@ -44,8 +42,7 @@ describe('Test plugin scripts', function () { killallServers([ server ]) await reRunServer(server) - const res = await getConfig(server.url) - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const plugin = config.plugin.registered .find(p => p.name === 'test') @@ -68,8 +65,7 @@ describe('Test plugin scripts', function () { killallServers([ server ]) await reRunServer(server) - const res = await getConfig(server.url) - const config: ServerConfig = res.body + const config = await server.configCommand.getConfig() const plugin = config.plugin.registered .find(p => p.name === 'test') -- cgit v1.2.3 From 9fff08cf83f34339df7ed4ac770e1dee536adf9d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 13:38:26 +0200 Subject: Introduce accounts command --- server/tests/cli/prune-storage.ts | 17 +++++++---------- server/tests/cli/update-host.ts | 18 ++++++++---------- 2 files changed, 15 insertions(+), 20 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 81f91105c..95f573e50 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -5,7 +5,7 @@ import * as chai from 'chai' import { createFile, readdir } from 'fs-extra' import { join } from 'path' import { buildUUID } from '@server/helpers/uuid' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '@shared/core-utils' import { buildServerDirectory, cleanupTests, @@ -13,7 +13,6 @@ import { createVideoPlaylist, doubleFollow, flushAndRunMultipleServers, - getAccount, killallServers, makeGetRequest, ServerInfo, @@ -21,10 +20,10 @@ import { setDefaultVideoChannel, updateMyAvatar, uploadVideo, - wait -} from '../../../shared/extra-utils' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { Account, VideoPlaylistPrivacy } from '../../../shared/models' + wait, + waitJobs +} from '@shared/extra-utils' +import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect @@ -94,8 +93,7 @@ describe('Test prune storage scripts', function () { // Lazy load the remote avatar { - const res = await getAccount(servers[0].url, 'root@localhost:' + servers[1].port) - const account: Account = res.body + const account = await servers[0].accountsCommand.get({ accountName: 'root@localhost:' + servers[1].port }) await makeGetRequest({ url: servers[0].url, path: account.avatar.path, @@ -104,8 +102,7 @@ describe('Test prune storage scripts', function () { } { - const res = await getAccount(servers[1].url, 'root@localhost:' + servers[0].port) - const account: Account = res.body + const account = await servers[1].accountsCommand.get({ accountName: 'root@localhost:' + servers[0].port }) await makeGetRequest({ url: servers[1].url, path: account.avatar.path, diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 1b1a76aef..f6131a99f 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -1,9 +1,9 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' -import * as chai from 'chai' import { addVideoChannel, + addVideoCommentThread, cleanupTests, createUser, flushAndRunServer, @@ -16,12 +16,10 @@ import { reRunServer, ServerInfo, setAccessTokensToServers, - uploadVideo -} from '../../../shared/extra-utils' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { getAccountsList } from '../../../shared/extra-utils/users/accounts' -import { addVideoCommentThread } from '../../../shared/extra-utils/videos/video-comments' -import { VideoDetails } from '../../../shared/models/videos' + uploadVideo, + waitJobs +} from '@shared/extra-utils' +import { VideoDetails } from '@shared/models' const expect = chai.expect @@ -104,10 +102,10 @@ describe('Test update host scripts', function () { }) it('Should have updated accounts url', async function () { - const res = await getAccountsList(server.url) - expect(res.body.total).to.equal(3) + const body = await server.accountsCommand.list() + expect(body.total).to.equal(3) - for (const account of res.body.data) { + for (const account of body.data) { const usernameWithDomain = account.name const { body } = await makeActivityPubGetRequest(server.url, '/accounts/' + usernameWithDomain) -- cgit v1.2.3 From e6346d59e63135cf012ed18c102d3b0179ef565f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 15:54:39 +0200 Subject: Introduce playlist command --- server/tests/cli/prune-storage.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 95f573e50..fa1df65a9 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -10,7 +10,6 @@ import { buildServerDirectory, cleanupTests, CLICommand, - createVideoPlaylist, doubleFollow, flushAndRunMultipleServers, killallServers, @@ -77,10 +76,8 @@ describe('Test prune storage scripts', function () { await updateMyAvatar({ url: server.url, accessToken: server.accessToken, fixture: 'avatar.png' }) - await createVideoPlaylist({ - url: server.url, - token: server.accessToken, - playlistAttrs: { + await server.playlistsCommand.create({ + attributes: { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: server.videoChannel.id, -- cgit v1.2.3 From 6910f20f114b5bd020258a3a9a3f2117819a60c2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Jul 2021 16:49:51 +0200 Subject: Introduce import command --- server/tests/cli/peertube.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 0a4f54ffa..64a93ebb5 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -15,6 +15,7 @@ import { getLocalIdByUUID, getVideo, getVideosList, + ImportsCommand, removeVideo, ServerInfo, setAccessTokensToServers, @@ -23,7 +24,6 @@ import { userLogin, waitJobs } from '../../../shared/extra-utils' -import { getYoutubeVideoUrl } from '../../../shared/extra-utils/videos/video-imports' describe('Test CLI wrapper', function () { let server: ServerInfo @@ -122,7 +122,7 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel` + const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} --channel-name user_channel` await cliCommand.execWithEnv(`${cmd} import ${params}`) }) @@ -155,7 +155,8 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const params = `--target-url ${getYoutubeVideoUrl()} --channel-name user_channel --video-name toto --nsfw --support support` + const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} ` + + `--channel-name user_channel --video-name toto --nsfw --support support` await cliCommand.execWithEnv(`${cmd} import ${params}`) await waitJobs([ server ]) -- cgit v1.2.3 From a54618880c394ad7571f3f3222dc96ec2dd10d9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 11:21:30 +0200 Subject: Introduce channels command --- server/tests/cli/peertube.ts | 5 ++--- server/tests/cli/update-host.ts | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 64a93ebb5..ef7ab5bd5 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -4,7 +4,6 @@ import 'mocha' import { expect } from 'chai' import { Video, VideoDetails } from '../../../shared' import { - addVideoChannel, areHttpImportTestsDisabled, buildAbsoluteFixturePath, cleanupTests, @@ -44,8 +43,8 @@ describe('Test CLI wrapper', function () { userAccessToken = await userLogin(server, { username: 'user_1', password: 'super_password' }) { - const args = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } - await addVideoChannel(server.url, userAccessToken, args) + const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } + await server.channelsCommand.create({ token: userAccessToken, attributes }) } cliCommand = server.cliCommand diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index f6131a99f..09a3dd1e7 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -2,13 +2,11 @@ import 'mocha' import { - addVideoChannel, addVideoCommentThread, cleanupTests, createUser, flushAndRunServer, getVideo, - getVideoChannelsList, getVideosList, killallServers, makeActivityPubGetRequest, @@ -53,7 +51,7 @@ describe('Test update host scripts', function () { displayName: 'second video channel', description: 'super video channel description' } - await addVideoChannel(server.url, server.accessToken, videoChannel) + await server.channelsCommand.create({ attributes: videoChannel }) // Create comments const text = 'my super first comment' @@ -91,10 +89,10 @@ describe('Test update host scripts', function () { }) it('Should have updated video channels url', async function () { - const res = await getVideoChannelsList(server.url, 0, 5, '-name') - expect(res.body.total).to.equal(3) + const { data, total } = await server.channelsCommand.list({ sort: '-name' }) + expect(total).to.equal(3) - for (const channel of res.body.data) { + for (const channel of data) { const { body } = await makeActivityPubGetRequest(server.url, '/video-channels/' + channel.name) expect(body.id).to.equal('http://localhost:9002/video-channels/' + channel.name) -- cgit v1.2.3 From 12edc1495a36b2199f1bf1ba37f50c7b694be382 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 14:15:11 +0200 Subject: Introduce comments command --- server/tests/cli/update-host.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 09a3dd1e7..61a6c403a 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -2,7 +2,6 @@ import 'mocha' import { - addVideoCommentThread, cleanupTests, createUser, flushAndRunServer, @@ -55,7 +54,7 @@ describe('Test update host scripts', function () { // Create comments const text = 'my super first comment' - await addVideoCommentThread(server.url, server.accessToken, video1UUID, text) + await server.commentsCommand.createThread({ videoId: video1UUID, text }) await waitJobs(server) }) -- cgit v1.2.3 From 078f17e6d90376050f43ce639e88e11869b49ee7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 15:03:44 +0200 Subject: Fix CLI tools --- server/tests/cli/peertube.ts | 9 +++++++++ server/tests/cli/update-host.ts | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index ef7ab5bd5..5ab07edb0 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -12,6 +12,7 @@ import { doubleFollow, flushAndRunServer, getLocalIdByUUID, + getMyUserInformation, getVideo, getVideosList, ImportsCommand, @@ -52,6 +53,14 @@ describe('Test CLI wrapper', function () { describe('Authentication and instance selection', function () { + it('Should get an access token', async function () { + const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`) + const token = stdout.trim() + + const res = await getMyUserInformation(server.url, token) + expect(res.body.username).to.equal('user_1') + }) + it('Should display no selected instance', async function () { this.timeout(60000) diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index 61a6c403a..d3a1520cf 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ import 'mocha' +import { expect } from 'chai' import { cleanupTests, createUser, @@ -18,8 +19,6 @@ import { } from '@shared/extra-utils' import { VideoDetails } from '@shared/models' -const expect = chai.expect - describe('Test update host scripts', function () { let server: ServerInfo -- cgit v1.2.3 From 9293139fde7091e9badcafa9b570b83cea9a10ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 9 Jul 2021 15:37:43 +0200 Subject: Introduce sql command --- server/tests/cli/plugins.ts | 4 ++-- server/tests/cli/prune-storage.ts | 2 +- server/tests/cli/update-host.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index e5efae36b..5344bfc96 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -39,7 +39,7 @@ describe('Test plugin scripts', function () { it('Should have the theme and the plugin registered when we restart peertube', async function () { this.timeout(30000) - killallServers([ server ]) + await killallServers([ server ]) await reRunServer(server) const config = await server.configCommand.getConfig() @@ -62,7 +62,7 @@ describe('Test plugin scripts', function () { it('Should have removed the plugin on another peertube restart', async function () { this.timeout(30000) - killallServers([ server ]) + await killallServers([ server ]) await reRunServer(server) const config = await server.configCommand.getConfig() diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index fa1df65a9..d4dbee682 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -110,7 +110,7 @@ describe('Test prune storage scripts', function () { await wait(1000) await waitJobs(servers) - killallServers(servers) + await killallServers(servers) await wait(1000) }) diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index d3a1520cf..e986a04f2 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -61,7 +61,7 @@ describe('Test update host scripts', function () { it('Should run update host', async function () { this.timeout(30000) - killallServers([ server ]) + await killallServers([ server ]) // Run server with standard configuration await reRunServer(server) -- cgit v1.2.3 From 6c5065a011b099618681a37bd77eaa7bd3db752e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 09:43:59 +0200 Subject: Introduce server commands --- server/tests/cli/optimize-old-videos.ts | 3 +-- server/tests/cli/prune-storage.ts | 31 +++++++++++++++---------------- server/tests/cli/regenerate-thumbnails.ts | 5 ++--- 3 files changed, 18 insertions(+), 21 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index bd15012fe..e369a3305 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -4,7 +4,6 @@ import 'mocha' import * as chai from 'chai' import { join } from 'path' import { - buildServerDirectory, cleanupTests, doubleFollow, flushAndRunMultipleServers, @@ -96,7 +95,7 @@ describe('Test optimize old videos', function () { expect(file.size).to.be.below(8000000) - const path = buildServerDirectory(servers[0], join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) + const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) const resolution = await getVideoFileResolution(path) diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index d4dbee682..68a59a41d 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -7,7 +7,6 @@ import { join } from 'path' import { buildUUID } from '@server/helpers/uuid' import { HttpStatusCode } from '@shared/core-utils' import { - buildServerDirectory, cleanupTests, CLICommand, doubleFollow, @@ -26,14 +25,14 @@ import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect -async function countFiles (internalServerNumber: number, directory: string) { - const files = await readdir(buildServerDirectory({ internalServerNumber }, directory)) +async function countFiles (server: ServerInfo, directory: string) { + const files = await readdir(server.serversCommand.buildDirectory(directory)) return files.length } -async function assertNotExists (internalServerNumber: number, directory: string, substring: string) { - const files = await readdir(buildServerDirectory({ internalServerNumber }, directory)) +async function assertNotExists (server: ServerInfo, directory: string, substring: string) { + const files = await readdir(server.serversCommand.buildDirectory(directory)) for (const f of files) { expect(f).to.not.contain(substring) @@ -42,19 +41,19 @@ async function assertNotExists (internalServerNumber: number, directory: string, async function assertCountAreOkay (servers: ServerInfo[]) { for (const server of servers) { - const videosCount = await countFiles(server.internalServerNumber, 'videos') + const videosCount = await countFiles(server, 'videos') expect(videosCount).to.equal(8) - const torrentsCount = await countFiles(server.internalServerNumber, 'torrents') + const torrentsCount = await countFiles(server, 'torrents') expect(torrentsCount).to.equal(16) - const previewsCount = await countFiles(server.internalServerNumber, 'previews') + const previewsCount = await countFiles(server, 'previews') expect(previewsCount).to.equal(2) - const thumbnailsCount = await countFiles(server.internalServerNumber, 'thumbnails') + const thumbnailsCount = await countFiles(server, 'thumbnails') expect(thumbnailsCount).to.equal(6) - const avatarsCount = await countFiles(server.internalServerNumber, 'avatars') + const avatarsCount = await countFiles(server, 'avatars') expect(avatarsCount).to.equal(2) } } @@ -122,7 +121,7 @@ describe('Test prune storage scripts', function () { it('Should create some dirty files', async function () { for (let i = 0; i < 2; i++) { { - const base = buildServerDirectory(servers[0], 'videos') + const base = servers[0].serversCommand.buildDirectory('videos') const n1 = buildUUID() + '.mp4' const n2 = buildUUID() + '.webm' @@ -134,7 +133,7 @@ describe('Test prune storage scripts', function () { } { - const base = buildServerDirectory(servers[0], 'torrents') + const base = servers[0].serversCommand.buildDirectory('torrents') const n1 = buildUUID() + '-240.torrent' const n2 = buildUUID() + '-480.torrent' @@ -146,7 +145,7 @@ describe('Test prune storage scripts', function () { } { - const base = buildServerDirectory(servers[0], 'thumbnails') + const base = servers[0].serversCommand.buildDirectory('thumbnails') const n1 = buildUUID() + '.jpg' const n2 = buildUUID() + '.jpg' @@ -158,7 +157,7 @@ describe('Test prune storage scripts', function () { } { - const base = buildServerDirectory(servers[0], 'previews') + const base = servers[0].serversCommand.buildDirectory('previews') const n1 = buildUUID() + '.jpg' const n2 = buildUUID() + '.jpg' @@ -170,7 +169,7 @@ describe('Test prune storage scripts', function () { } { - const base = buildServerDirectory(servers[0], 'avatars') + const base = servers[0].serversCommand.buildDirectory('avatars') const n1 = buildUUID() + '.png' const n2 = buildUUID() + '.jpg' @@ -195,7 +194,7 @@ describe('Test prune storage scripts', function () { for (const directory of Object.keys(badNames)) { for (const name of badNames[directory]) { - await assertNotExists(servers[0].internalServerNumber, directory, name) + await assertNotExists(servers[0], directory, name) } } }) diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index 1b460e9c0..68a4711b6 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -4,7 +4,6 @@ import { writeFile } from 'fs-extra' import { basename, join } from 'path' import { Video, VideoDetails } from '@shared/models' import { - buildServerDirectory, cleanupTests, doubleFollow, flushAndRunMultipleServers, @@ -50,7 +49,7 @@ describe('Test regenerate thumbnails script', function () { const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body)) - thumbnail1Path = join(buildServerDirectory(servers[0], 'thumbnails'), basename(video1.thumbnailPath)) + thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body)) @@ -62,7 +61,7 @@ describe('Test regenerate thumbnails script', function () { remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body)) - thumbnailRemotePath = join(buildServerDirectory(servers[0], 'thumbnails'), basename(remoteVideo.thumbnailPath)) + thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) } await writeFile(thumbnail1Path, '') -- cgit v1.2.3 From 41d1d075011174e73dccb74006181a92a618d7b4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 11:05:15 +0200 Subject: Introduce login command --- server/tests/cli/peertube.ts | 3 +-- server/tests/cli/reset-password.ts | 13 ++----------- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 5ab07edb0..e055b4684 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -21,7 +21,6 @@ import { setAccessTokensToServers, testHelloWorldRegisteredSettings, uploadVideoAndGetId, - userLogin, waitJobs } from '../../../shared/extra-utils' @@ -41,7 +40,7 @@ describe('Test CLI wrapper', function () { await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super_password' }) - userAccessToken = await userLogin(server, { username: 'user_1', password: 'super_password' }) + userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' }) { const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index 97a6eae15..a5f958bf7 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts @@ -1,14 +1,5 @@ import 'mocha' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' -import { - cleanupTests, - CLICommand, - createUser, - flushAndRunServer, - login, - ServerInfo, - setAccessTokensToServers -} from '../../../shared/extra-utils' +import { cleanupTests, CLICommand, createUser, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils' describe('Test reset password scripts', function () { let server: ServerInfo @@ -27,7 +18,7 @@ describe('Test reset password scripts', function () { const env = server.cliCommand.getEnv() await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`) - await login(server.url, server.client, { username: 'user_1', password: 'coucou' }, HttpStatusCode.OK_200) + await server.loginCommand.login({ user: { username: 'user_1', password: 'coucou' } }) }) after(async function () { -- cgit v1.2.3 From 7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Jul 2021 14:23:01 +0200 Subject: Introduce user command --- server/tests/cli/peertube.ts | 8 +++----- server/tests/cli/prune-storage.ts | 3 +-- server/tests/cli/reset-password.ts | 4 ++-- server/tests/cli/update-host.ts | 3 +-- 4 files changed, 7 insertions(+), 11 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index e055b4684..a0c149ac0 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -8,11 +8,9 @@ import { buildAbsoluteFixturePath, cleanupTests, CLICommand, - createUser, doubleFollow, flushAndRunServer, getLocalIdByUUID, - getMyUserInformation, getVideo, getVideosList, ImportsCommand, @@ -38,7 +36,7 @@ describe('Test CLI wrapper', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super_password' }) + await server.usersCommand.create({ username: 'user_1', password: 'super_password' }) userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' }) @@ -56,8 +54,8 @@ describe('Test CLI wrapper', function () { const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`) const token = stdout.trim() - const res = await getMyUserInformation(server.url, token) - expect(res.body.username).to.equal('user_1') + const body = await server.usersCommand.getMyInfo({ token }) + expect(body.username).to.equal('user_1') }) it('Should display no selected instance', async function () { diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 68a59a41d..b45049964 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -16,7 +16,6 @@ import { ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, - updateMyAvatar, uploadVideo, wait, waitJobs @@ -73,7 +72,7 @@ describe('Test prune storage scripts', function () { await uploadVideo(server.url, server.accessToken, { name: 'video 1' }) await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) - await updateMyAvatar({ url: server.url, accessToken: server.accessToken, fixture: 'avatar.png' }) + await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) await server.playlistsCommand.create({ attributes: { diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index a5f958bf7..5e1e1c2af 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts @@ -1,5 +1,5 @@ import 'mocha' -import { cleanupTests, CLICommand, createUser, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils' +import { cleanupTests, CLICommand, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils' describe('Test reset password scripts', function () { let server: ServerInfo @@ -9,7 +9,7 @@ describe('Test reset password scripts', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super password' }) + await server.usersCommand.create({ username: 'user_1', password: 'super password' }) }) it('Should change the user password from CLI', async function () { diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index e986a04f2..b857fcf28 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -4,7 +4,6 @@ import 'mocha' import { expect } from 'chai' import { cleanupTests, - createUser, flushAndRunServer, getVideo, getVideosList, @@ -41,7 +40,7 @@ describe('Test update host scripts', function () { await uploadVideo(server.url, server.accessToken, videoAttributes) // Create a user - await createUser({ url: server.url, accessToken: server.accessToken, username: 'toto', password: 'coucou' }) + await server.usersCommand.create({ username: 'toto', password: 'coucou' }) // Create channel const videoChannel = { -- cgit v1.2.3 From d23dd9fbfc4d26026352c10f81d2795ceaf2908a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Jul 2021 10:02:54 +0200 Subject: Introduce videos command --- server/tests/cli/create-import-video-file-job.ts | 52 +++++++--------- server/tests/cli/create-transcoding-job.ts | 76 ++++++++++-------------- server/tests/cli/optimize-old-videos.ts | 47 ++++++--------- server/tests/cli/peertube.ts | 41 +++++-------- server/tests/cli/prune-storage.ts | 5 +- server/tests/cli/regenerate-thumbnails.ts | 33 +++++----- server/tests/cli/update-host.ts | 29 ++++----- 7 files changed, 116 insertions(+), 167 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 8a23a94de..b1d9da242 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -2,19 +2,8 @@ import 'mocha' import * as chai from 'chai' -import { VideoFile } from '@shared/models/videos/video-file.model' -import { - cleanupTests, - doubleFollow, - flushAndRunMultipleServers, - getVideo, - getVideosList, - ServerInfo, - setAccessTokensToServers, - uploadVideo -} from '../../../shared/extra-utils' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { VideoDetails } from '../../../shared/models/videos' +import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' +import { VideoFile } from '@shared/models' const expect = chai.expect @@ -45,10 +34,15 @@ describe('Test create import video jobs', function () { await doubleFollow(servers[0], servers[1]) // Upload two videos for our needs - const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1' }) - video1UUID = res1.body.video.uuid - const res2 = await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'video2' }) - video2UUID = res2.body.video.uuid + { + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video1' } }) + video1UUID = uuid + } + + { + const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video2' } }) + video2UUID = uuid + } // Transcoding await waitJobs(servers) @@ -61,14 +55,14 @@ describe('Test create import video jobs', function () { await waitJobs(servers) for (const server of servers) { - const { data: videos } = (await getVideosList(server.url)).body + const { data: videos } = await server.videosCommand.list() expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video1UUID) - const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body + const videoDetails = await server.videosCommand.get({ id: video.uuid }) - expect(videoDetail.files).to.have.lengthOf(2) - const [ originalVideo, transcodedVideo ] = videoDetail.files + expect(videoDetails.files).to.have.lengthOf(2) + const [ originalVideo, transcodedVideo ] = videoDetails.files assertVideoProperties(originalVideo, 720, 'webm', 218910) assertVideoProperties(transcodedVideo, 480, 'webm', 69217) } @@ -81,14 +75,14 @@ describe('Test create import video jobs', function () { await waitJobs(servers) for (const server of servers) { - const { data: videos } = (await getVideosList(server.url)).body + const { data: videos } = await server.videosCommand.list() expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video2UUID) - const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body + const videoDetails = await server.videosCommand.get({ id: video.uuid }) - expect(videoDetail.files).to.have.lengthOf(4) - const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetail.files + expect(videoDetails.files).to.have.lengthOf(4) + const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files assertVideoProperties(originalVideo, 720, 'ogv', 140849) assertVideoProperties(transcodedVideo420, 480, 'mp4') assertVideoProperties(transcodedVideo320, 360, 'mp4') @@ -103,14 +97,14 @@ describe('Test create import video jobs', function () { await waitJobs(servers) for (const server of servers) { - const { data: videos } = (await getVideosList(server.url)).body + const { data: videos } = await server.videosCommand.list() expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video1UUID) - const videoDetail: VideoDetails = (await getVideo(server.url, video.uuid)).body + const videoDetails = await server.videosCommand.get({ id: video.uuid }) - expect(videoDetail.files).to.have.lengthOf(2) - const [ video720, video480 ] = videoDetail.files + expect(videoDetails.files).to.have.lengthOf(2) + const [ video720, video480 ] = videoDetails.files assertVideoProperties(video720, 720, 'webm', 942961) assertVideoProperties(video480, 480, 'webm', 69217) } diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index e3211882d..f629306e6 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -6,14 +6,10 @@ import { cleanupTests, doubleFollow, flushAndRunMultipleServers, - getVideo, - getVideosList, ServerInfo, setAccessTokensToServers, - uploadVideo + waitJobs } from '../../../shared/extra-utils' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { VideoDetails } from '../../../shared/models/videos' const expect = chai.expect @@ -51,8 +47,8 @@ describe('Test create transcoding jobs', function () { await doubleFollow(servers[0], servers[1]) for (let i = 1; i <= 5; i++) { - const res = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video' + i }) - videosUUID.push(res.body.video.uuid) + const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' + i } }) + videosUUID.push(uuid) } await waitJobs(servers) @@ -62,13 +58,11 @@ describe('Test create transcoding jobs', function () { this.timeout(30000) for (const server of servers) { - const res = await getVideosList(server.url) - const videos = res.body.data - expect(videos).to.have.lengthOf(videosUUID.length) + const { data } = await server.videosCommand.list() + expect(data).to.have.lengthOf(videosUUID.length) - for (const video of videos) { - const res2 = await getVideo(server.url, video.uuid) - const videoDetail: VideoDetails = res2.body + for (const video of data) { + const videoDetail = await server.videosCommand.get({ id: video.uuid }) expect(videoDetail.files).to.have.lengthOf(1) expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) } @@ -82,14 +76,12 @@ describe('Test create transcoding jobs', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideosList(server.url) - const videos = res.body.data + const { data } = await server.videosCommand.list() let infoHashes: { [id: number]: string } - for (const video of videos) { - const res2 = await getVideo(server.url, video.uuid) - const videoDetail: VideoDetails = res2.body + for (const video of data) { + const videoDetail = await server.videosCommand.get({ id: video.uuid }) if (video.uuid === videosUUID[1]) { expect(videoDetail.files).to.have.lengthOf(4) @@ -123,18 +115,16 @@ describe('Test create transcoding jobs', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideosList(server.url) - const videos = res.body.data - expect(videos).to.have.lengthOf(videosUUID.length) + const { data } = await server.videosCommand.list() + expect(data).to.have.lengthOf(videosUUID.length) - const res2 = await getVideo(server.url, videosUUID[0]) - const videoDetail: VideoDetails = res2.body + const videoDetails = await server.videosCommand.get({ id: videosUUID[0] }) - expect(videoDetail.files).to.have.lengthOf(2) - expect(videoDetail.files[0].resolution.id).to.equal(720) - expect(videoDetail.files[1].resolution.id).to.equal(480) + expect(videoDetails.files).to.have.lengthOf(2) + expect(videoDetails.files[0].resolution.id).to.equal(720) + expect(videoDetails.files[1].resolution.id).to.equal(480) - expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) + expect(videoDetails.streamingPlaylists).to.have.lengthOf(0) } }) @@ -146,13 +136,12 @@ describe('Test create transcoding jobs', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideo(server.url, videosUUID[2]) - const videoDetail: VideoDetails = res.body + const videoDetails = await server.videosCommand.get({ id: videosUUID[2] }) - expect(videoDetail.files).to.have.lengthOf(1) - expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) + expect(videoDetails.files).to.have.lengthOf(1) + expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) - const files = videoDetail.streamingPlaylists[0].files + const files = videoDetails.streamingPlaylists[0].files expect(files).to.have.lengthOf(1) expect(files[0].resolution.id).to.equal(480) } @@ -166,10 +155,9 @@ describe('Test create transcoding jobs', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideo(server.url, videosUUID[2]) - const videoDetail: VideoDetails = res.body + const videoDetails = await server.videosCommand.get({ id: videosUUID[2] }) - const files = videoDetail.streamingPlaylists[0].files + const files = videoDetails.streamingPlaylists[0].files expect(files).to.have.lengthOf(1) expect(files[0].resolution.id).to.equal(480) } @@ -183,13 +171,12 @@ describe('Test create transcoding jobs', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideo(server.url, videosUUID[3]) - const videoDetail: VideoDetails = res.body + const videoDetails = await server.videosCommand.get({ id: videosUUID[3] }) - expect(videoDetail.files).to.have.lengthOf(1) - expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) + expect(videoDetails.files).to.have.lengthOf(1) + expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) - const files = videoDetail.streamingPlaylists[0].files + const files = videoDetails.streamingPlaylists[0].files expect(files).to.have.lengthOf(4) } }) @@ -205,12 +192,11 @@ describe('Test create transcoding jobs', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideo(server.url, videosUUID[4]) - const videoDetail: VideoDetails = res.body + const videoDetails = await server.videosCommand.get({ id: videosUUID[4] }) - expect(videoDetail.files).to.have.lengthOf(4) - expect(videoDetail.streamingPlaylists).to.have.lengthOf(1) - expect(videoDetail.streamingPlaylists[0].files).to.have.lengthOf(4) + expect(videoDetails.files).to.have.lengthOf(4) + expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) + expect(videoDetails.streamingPlaylists[0].files).to.have.lengthOf(4) } }) diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index e369a3305..ef8603a33 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -8,16 +8,12 @@ import { doubleFollow, flushAndRunMultipleServers, generateHighBitrateVideo, - getVideo, - getVideosList, ServerInfo, setAccessTokensToServers, - uploadVideo, - viewVideo, - wait -} from '../../../shared/extra-utils' -import { waitJobs } from '../../../shared/extra-utils/server/jobs' -import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos' + wait, + waitJobs +} from '@shared/extra-utils' +import { getMaxBitrate, VideoResolution } from '@shared/models' import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils' import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' @@ -45,8 +41,8 @@ describe('Test optimize old videos', function () { } // Upload two videos for our needs - await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1', fixture: tempFixturePath }) - await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2', fixture: tempFixturePath }) + await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } }) + await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } }) await waitJobs(servers) }) @@ -55,14 +51,12 @@ describe('Test optimize old videos', function () { this.timeout(30000) for (const server of servers) { - const res = await getVideosList(server.url) - const videos = res.body.data - expect(videos).to.have.lengthOf(2) - - for (const video of videos) { - const res2 = await getVideo(server.url, video.uuid) - const videoDetail: VideoDetails = res2.body - expect(videoDetail.files).to.have.lengthOf(1) + const { data } = await server.videosCommand.list() + expect(data).to.have.lengthOf(2) + + for (const video of data) { + const videoDetails = await server.videosCommand.get({ id: video.uuid }) + expect(videoDetails.files).to.have.lengthOf(1) } } }) @@ -74,24 +68,21 @@ describe('Test optimize old videos', function () { await waitJobs(servers) for (const server of servers) { - const res = await getVideosList(server.url) - const videos: Video[] = res.body.data - - expect(videos).to.have.lengthOf(2) + const { data } = await server.videosCommand.list() + expect(data).to.have.lengthOf(2) - for (const video of videos) { - await viewVideo(server.url, video.uuid) + for (const video of data) { + await server.videosCommand.view({ id: video.uuid }) // Refresh video await waitJobs(servers) await wait(5000) await waitJobs(servers) - const res2 = await getVideo(server.url, video.uuid) - const videosDetails: VideoDetails = res2.body + const videoDetails = await server.videosCommand.get({ id: video.uuid }) - expect(videosDetails.files).to.have.lengthOf(1) - const file = videosDetails.files[0] + expect(videoDetails.files).to.have.lengthOf(1) + const file = videoDetails.files[0] expect(file.size).to.be.below(8000000) diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index a0c149ac0..fe5f63191 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -2,7 +2,6 @@ import 'mocha' import { expect } from 'chai' -import { Video, VideoDetails } from '../../../shared' import { areHttpImportTestsDisabled, buildAbsoluteFixturePath, @@ -10,15 +9,10 @@ import { CLICommand, doubleFollow, flushAndRunServer, - getLocalIdByUUID, - getVideo, - getVideosList, ImportsCommand, - removeVideo, ServerInfo, setAccessTokensToServers, testHelloWorldRegisteredSettings, - uploadVideoAndGetId, waitJobs } from '../../../shared/extra-utils' @@ -109,14 +103,10 @@ describe('Test CLI wrapper', function () { }) it('Should have the video uploaded', async function () { - const res = await getVideosList(server.url) - - expect(res.body.total).to.equal(1) - - const videos: Video[] = res.body.data - - const video: VideoDetails = (await getVideo(server.url, videos[0].uuid)).body + const { total, data } = await server.videosCommand.list() + expect(total).to.equal(1) + const video = await server.videosCommand.get({ id: data[0].uuid }) expect(video.name).to.equal('test upload') expect(video.support).to.equal('support_text') expect(video.channel.name).to.equal('user_channel') @@ -138,21 +128,19 @@ describe('Test CLI wrapper', function () { await waitJobs([ server ]) - const res = await getVideosList(server.url) - - expect(res.body.total).to.equal(2) + const { total, data } = await server.videosCommand.list() + expect(total).to.equal(2) - const videos: Video[] = res.body.data - const video = videos.find(v => v.name === 'small video - youtube') + const video = data.find(v => v.name === 'small video - youtube') expect(video).to.not.be.undefined - const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body + const videoDetails = await server.videosCommand.get({ id: video.id }) expect(videoDetails.channel.name).to.equal('user_channel') expect(videoDetails.support).to.equal('super support text') expect(videoDetails.nsfw).to.be.false // So we can reimport it - await removeVideo(server.url, userAccessToken, video.id) + await server.videosCommand.remove({ token: userAccessToken, id: video.id }) }) it('Should import and override some imported attributes', async function () { @@ -167,14 +155,13 @@ describe('Test CLI wrapper', function () { await waitJobs([ server ]) { - const res = await getVideosList(server.url) - expect(res.body.total).to.equal(2) + const { total, data } = await server.videosCommand.list() + expect(total).to.equal(2) - const videos: Video[] = res.body.data - const video = videos.find(v => v.name === 'toto') + const video = data.find(v => v.name === 'toto') expect(video).to.not.be.undefined - const videoDetails: VideoDetails = (await getVideo(server.url, video.id)).body + const videoDetails = await server.videosCommand.get({ id: video.id }) expect(videoDetails.channel.name).to.equal('user_channel') expect(videoDetails.support).to.equal('support') expect(videoDetails.nsfw).to.be.true @@ -238,10 +225,10 @@ describe('Test CLI wrapper', function () { servers = [ server, anotherServer ] await waitJobs(servers) - const uuid = (await uploadVideoAndGetId({ server: anotherServer, videoName: 'super video' })).uuid + const { uuid } = await anotherServer.videosCommand.quickUpload({ name: 'super video' }) await waitJobs(servers) - video1Server2 = await getLocalIdByUUID(server.url, uuid) + video1Server2 = await server.videosCommand.getId({ uuid }) }) it('Should add a redundancy', async function () { diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index b45049964..a4556312b 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -16,7 +16,6 @@ import { ServerInfo, setAccessTokensToServers, setDefaultVideoChannel, - uploadVideo, wait, waitJobs } from '@shared/extra-utils' @@ -69,8 +68,8 @@ describe('Test prune storage scripts', function () { await setDefaultVideoChannel(servers) for (const server of servers) { - await uploadVideo(server.url, server.accessToken, { name: 'video 1' }) - await uploadVideo(server.url, server.accessToken, { name: 'video 2' }) + await server.videosCommand.upload({ attributes: { name: 'video 1' } }) + await server.videosCommand.upload({ attributes: { name: 'video 2' } }) await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index 68a4711b6..d59520783 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -2,29 +2,30 @@ import 'mocha' import { expect } from 'chai' import { writeFile } from 'fs-extra' import { basename, join } from 'path' -import { Video, VideoDetails } from '@shared/models' +import { HttpStatusCode } from '@shared/core-utils' +import { Video } from '@shared/models' import { cleanupTests, doubleFollow, flushAndRunMultipleServers, - getVideo, makeRawRequest, ServerInfo, setAccessTokensToServers, - uploadVideoAndGetId, waitJobs } from '../../../shared/extra-utils' -import { HttpStatusCode } from '@shared/core-utils' async function testThumbnail (server: ServerInfo, videoId: number | string) { - const res = await getVideo(server.url, videoId) - const video: VideoDetails = res.body + const video = await server.videosCommand.get({ id: videoId }) - const res1 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) - expect(res1.body).to.not.have.lengthOf(0) + const requests = [ + makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200), + makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) + ] - const res2 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) - expect(res2.body).to.not.have.lengthOf(0) + for (const req of requests) { + const res = await req + expect(res.body).to.not.have.lengthOf(0) + } } describe('Test regenerate thumbnails script', function () { @@ -46,20 +47,20 @@ describe('Test regenerate thumbnails script', function () { await doubleFollow(servers[0], servers[1]) { - const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid - video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body)) + const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid + video1 = await servers[0].videosCommand.get({ id: videoUUID1 }) thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) - const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid - video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body)) + const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid + video2 = await servers[0].videosCommand.get({ id: videoUUID2 }) } { - const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3' })).uuid + const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid await waitJobs(servers) - remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body)) + remoteVideo = await servers[0].videosCommand.get({ id: videoUUID }) thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) } diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index b857fcf28..d90b4a64d 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -5,18 +5,14 @@ import { expect } from 'chai' import { cleanupTests, flushAndRunServer, - getVideo, - getVideosList, killallServers, makeActivityPubGetRequest, parseTorrentVideo, reRunServer, ServerInfo, setAccessTokensToServers, - uploadVideo, waitJobs } from '@shared/extra-utils' -import { VideoDetails } from '@shared/models' describe('Test update host scripts', function () { let server: ServerInfo @@ -34,10 +30,8 @@ describe('Test update host scripts', function () { await setAccessTokensToServers([ server ]) // Upload two videos for our needs - const videoAttributes = {} - const resVideo1 = await uploadVideo(server.url, server.accessToken, videoAttributes) - const video1UUID = resVideo1.body.video.uuid - await uploadVideo(server.url, server.accessToken, videoAttributes) + const { uuid: video1UUID } = await server.videosCommand.upload() + await server.videosCommand.upload() // Create a user await server.usersCommand.create({ username: 'toto', password: 'coucou' }) @@ -68,16 +62,15 @@ describe('Test update host scripts', function () { }) it('Should have updated videos url', async function () { - const res = await getVideosList(server.url) - expect(res.body.total).to.equal(2) + const { total, data } = await server.videosCommand.list() + expect(total).to.equal(2) - for (const video of res.body.data) { + for (const video of data) { const { body } = await makeActivityPubGetRequest(server.url, '/videos/watch/' + video.uuid) expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) - const res = await getVideo(server.url, video.uuid) - const videoDetails: VideoDetails = res.body + const videoDetails = await server.videosCommand.get({ id: video.uuid }) expect(videoDetails.trackerUrls[0]).to.include(server.host) expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host) @@ -111,13 +104,11 @@ describe('Test update host scripts', function () { it('Should have updated torrent hosts', async function () { this.timeout(30000) - const res = await getVideosList(server.url) - const videos = res.body.data - expect(videos).to.have.lengthOf(2) + const { data } = await server.videosCommand.list() + expect(data).to.have.lengthOf(2) - for (const video of videos) { - const res2 = await getVideo(server.url, video.id) - const videoDetails: VideoDetails = res2.body + for (const video of data) { + const videoDetails = await server.videosCommand.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) -- cgit v1.2.3 From 89d241a79c262b9775c233b73cff080043ebb5e6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:04:35 +0200 Subject: Shorter server command names --- server/tests/cli/create-import-video-file-job.ts | 22 +++++++------- server/tests/cli/create-transcoding-job.ts | 38 ++++++++++++------------ server/tests/cli/optimize-old-videos.ts | 18 +++++------ server/tests/cli/peertube.ts | 28 ++++++++--------- server/tests/cli/plugins.ts | 10 +++---- server/tests/cli/prune-storage.ts | 30 +++++++++---------- server/tests/cli/regenerate-thumbnails.ts | 20 ++++++------- server/tests/cli/reset-password.ts | 6 ++-- server/tests/cli/update-host.ts | 24 +++++++-------- 9 files changed, 98 insertions(+), 98 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index b1d9da242..26f4bdc8d 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -35,12 +35,12 @@ describe('Test create import video jobs', function () { // Upload two videos for our needs { - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video1' } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } }) video1UUID = uuid } { - const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video2' } }) + const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video2' } }) video2UUID = uuid } @@ -50,16 +50,16 @@ describe('Test create import video jobs', function () { it('Should run a import job on video 1 with a lower resolution', async function () { const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm` - await servers[0].cliCommand.execWithEnv(command) + await servers[0].cli.execWithEnv(command) await waitJobs(servers) for (const server of servers) { - const { data: videos } = await server.videosCommand.list() + const { data: videos } = await server.videos.list() expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video1UUID) - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(2) const [ originalVideo, transcodedVideo ] = videoDetails.files @@ -70,16 +70,16 @@ describe('Test create import video jobs', function () { it('Should run a import job on video 2 with the same resolution and a different extension', async function () { const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv` - await servers[1].cliCommand.execWithEnv(command) + await servers[1].cli.execWithEnv(command) await waitJobs(servers) for (const server of servers) { - const { data: videos } = await server.videosCommand.list() + const { data: videos } = await server.videos.list() expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video2UUID) - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(4) const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files @@ -92,16 +92,16 @@ describe('Test create import video jobs', function () { it('Should run a import job on video 2 with the same resolution and the same extension', async function () { const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm` - await servers[0].cliCommand.execWithEnv(command) + await servers[0].cli.execWithEnv(command) await waitJobs(servers) for (const server of servers) { - const { data: videos } = await server.videosCommand.list() + const { data: videos } = await server.videos.list() expect(videos).to.have.lengthOf(2) const video = videos.find(({ uuid }) => uuid === video1UUID) - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(2) const [ video720, video480 ] = videoDetails.files diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index f629306e6..c9bbab802 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -42,12 +42,12 @@ describe('Test create transcoding jobs', function () { servers = await flushAndRunMultipleServers(2) await setAccessTokensToServers(servers) - await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) + await servers[0].config.updateCustomSubConfig({ newConfig: config }) await doubleFollow(servers[0], servers[1]) for (let i = 1; i <= 5; i++) { - const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' + i } }) + const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } }) videosUUID.push(uuid) } @@ -58,11 +58,11 @@ describe('Test create transcoding jobs', function () { this.timeout(30000) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.have.lengthOf(videosUUID.length) for (const video of data) { - const videoDetail = await server.videosCommand.get({ id: video.uuid }) + const videoDetail = await server.videos.get({ id: video.uuid }) expect(videoDetail.files).to.have.lengthOf(1) expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) } @@ -72,16 +72,16 @@ describe('Test create transcoding jobs', function () { it('Should run a transcoding job on video 2', async function () { this.timeout(60000) - await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`) + await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() let infoHashes: { [id: number]: string } for (const video of data) { - const videoDetail = await server.videosCommand.get({ id: video.uuid }) + const videoDetail = await server.videos.get({ id: video.uuid }) if (video.uuid === videosUUID[1]) { expect(videoDetail.files).to.have.lengthOf(4) @@ -110,15 +110,15 @@ describe('Test create transcoding jobs', function () { it('Should run a transcoding job on video 1 with resolution', async function () { this.timeout(60000) - await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`) + await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`) await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.have.lengthOf(videosUUID.length) - const videoDetails = await server.videosCommand.get({ id: videosUUID[0] }) + const videoDetails = await server.videos.get({ id: videosUUID[0] }) expect(videoDetails.files).to.have.lengthOf(2) expect(videoDetails.files[0].resolution.id).to.equal(720) @@ -131,12 +131,12 @@ describe('Test create transcoding jobs', function () { it('Should generate an HLS resolution', async function () { this.timeout(120000) - await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) + await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) await waitJobs(servers) for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videosUUID[2] }) + const videoDetails = await server.videos.get({ id: videosUUID[2] }) expect(videoDetails.files).to.have.lengthOf(1) expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) @@ -150,12 +150,12 @@ describe('Test create transcoding jobs', function () { it('Should not duplicate an HLS resolution', async function () { this.timeout(120000) - await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) + await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) await waitJobs(servers) for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videosUUID[2] }) + const videoDetails = await server.videos.get({ id: videosUUID[2] }) const files = videoDetails.streamingPlaylists[0].files expect(files).to.have.lengthOf(1) @@ -166,12 +166,12 @@ describe('Test create transcoding jobs', function () { it('Should generate all HLS resolutions', async function () { this.timeout(120000) - await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`) + await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`) await waitJobs(servers) for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videosUUID[3] }) + const videoDetails = await server.videos.get({ id: videosUUID[3] }) expect(videoDetails.files).to.have.lengthOf(1) expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) @@ -185,14 +185,14 @@ describe('Test create transcoding jobs', function () { this.timeout(120000) config.transcoding.hls.enabled = true - await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) + await servers[0].config.updateCustomSubConfig({ newConfig: config }) - await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`) + await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`) await waitJobs(servers) for (const server of servers) { - const videoDetails = await server.videosCommand.get({ id: videosUUID[4] }) + const videoDetails = await server.videos.get({ id: videosUUID[4] }) expect(videoDetails.files).to.have.lengthOf(4) expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index ef8603a33..eefc95a6d 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -41,8 +41,8 @@ describe('Test optimize old videos', function () { } // Upload two videos for our needs - await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } }) - await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } }) + await servers[0].videos.upload({ attributes: { name: 'video1', fixture: tempFixturePath } }) + await servers[0].videos.upload({ attributes: { name: 'video2', fixture: tempFixturePath } }) await waitJobs(servers) }) @@ -51,11 +51,11 @@ describe('Test optimize old videos', function () { this.timeout(30000) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.have.lengthOf(2) for (const video of data) { - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(1) } } @@ -64,29 +64,29 @@ describe('Test optimize old videos', function () { it('Should run optimize script', async function () { this.timeout(200000) - await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos') + await servers[0].cli.execWithEnv('npm run optimize-old-videos') await waitJobs(servers) for (const server of servers) { - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.have.lengthOf(2) for (const video of data) { - await server.videosCommand.view({ id: video.uuid }) + await server.videos.view({ id: video.uuid }) // Refresh video await waitJobs(servers) await wait(5000) await waitJobs(servers) - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.files).to.have.lengthOf(1) const file = videoDetails.files[0] expect(file.size).to.be.below(8000000) - const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) + const path = servers[0].servers.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) const bitrate = await getVideoFileBitrate(path) const fps = await getVideoFileFPS(path) const resolution = await getVideoFileResolution(path) diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index fe5f63191..a83aa7724 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -30,16 +30,16 @@ describe('Test CLI wrapper', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await server.usersCommand.create({ username: 'user_1', password: 'super_password' }) + await server.users.create({ username: 'user_1', password: 'super_password' }) - userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' }) + userAccessToken = await server.login.getAccessToken({ username: 'user_1', password: 'super_password' }) { const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } - await server.channelsCommand.create({ token: userAccessToken, attributes }) + await server.channels.create({ token: userAccessToken, attributes }) } - cliCommand = server.cliCommand + cliCommand = server.cli }) describe('Authentication and instance selection', function () { @@ -48,7 +48,7 @@ describe('Test CLI wrapper', function () { const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`) const token = stdout.trim() - const body = await server.usersCommand.getMyInfo({ token }) + const body = await server.users.getMyInfo({ token }) expect(body.username).to.equal('user_1') }) @@ -103,10 +103,10 @@ describe('Test CLI wrapper', function () { }) it('Should have the video uploaded', async function () { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(1) - const video = await server.videosCommand.get({ id: data[0].uuid }) + const video = await server.videos.get({ id: data[0].uuid }) expect(video.name).to.equal('test upload') expect(video.support).to.equal('support_text') expect(video.channel.name).to.equal('user_channel') @@ -128,19 +128,19 @@ describe('Test CLI wrapper', function () { await waitJobs([ server ]) - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(2) const video = data.find(v => v.name === 'small video - youtube') expect(video).to.not.be.undefined - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.channel.name).to.equal('user_channel') expect(videoDetails.support).to.equal('super support text') expect(videoDetails.nsfw).to.be.false // So we can reimport it - await server.videosCommand.remove({ token: userAccessToken, id: video.id }) + await server.videos.remove({ token: userAccessToken, id: video.id }) }) it('Should import and override some imported attributes', async function () { @@ -155,13 +155,13 @@ describe('Test CLI wrapper', function () { await waitJobs([ server ]) { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(2) const video = data.find(v => v.name === 'toto') expect(video).to.not.be.undefined - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.channel.name).to.equal('user_channel') expect(videoDetails.support).to.equal('support') expect(videoDetails.nsfw).to.be.true @@ -225,10 +225,10 @@ describe('Test CLI wrapper', function () { servers = [ server, anotherServer ] await waitJobs(servers) - const { uuid } = await anotherServer.videosCommand.quickUpload({ name: 'super video' }) + const { uuid } = await anotherServer.videos.quickUpload({ name: 'super video' }) await waitJobs(servers) - video1Server2 = await server.videosCommand.getId({ uuid }) + video1Server2 = await server.videos.getId({ uuid }) }) it('Should add a redundancy', async function () { diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index 5344bfc96..178a7a2d9 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -27,13 +27,13 @@ describe('Test plugin scripts', function () { const packagePath = PluginsCommand.getPluginTestPath() - await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) + await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) }) it('Should install a theme from stateless CLI', async function () { this.timeout(60000) - await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`) + await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`) }) it('Should have the theme and the plugin registered when we restart peertube', async function () { @@ -42,7 +42,7 @@ describe('Test plugin scripts', function () { await killallServers([ server ]) await reRunServer(server) - const config = await server.configCommand.getConfig() + const config = await server.config.getConfig() const plugin = config.plugin.registered .find(p => p.name === 'test') @@ -56,7 +56,7 @@ describe('Test plugin scripts', function () { it('Should uninstall a plugin from stateless CLI', async function () { this.timeout(60000) - await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`) + await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`) }) it('Should have removed the plugin on another peertube restart', async function () { @@ -65,7 +65,7 @@ describe('Test plugin scripts', function () { await killallServers([ server ]) await reRunServer(server) - const config = await server.configCommand.getConfig() + const config = await server.config.getConfig() const plugin = config.plugin.registered .find(p => p.name === 'test') diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index a4556312b..9912a36e0 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -24,13 +24,13 @@ import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect async function countFiles (server: ServerInfo, directory: string) { - const files = await readdir(server.serversCommand.buildDirectory(directory)) + const files = await readdir(server.servers.buildDirectory(directory)) return files.length } async function assertNotExists (server: ServerInfo, directory: string, substring: string) { - const files = await readdir(server.serversCommand.buildDirectory(directory)) + const files = await readdir(server.servers.buildDirectory(directory)) for (const f of files) { expect(f).to.not.contain(substring) @@ -68,16 +68,16 @@ describe('Test prune storage scripts', function () { await setDefaultVideoChannel(servers) for (const server of servers) { - await server.videosCommand.upload({ attributes: { name: 'video 1' } }) - await server.videosCommand.upload({ attributes: { name: 'video 2' } }) + await server.videos.upload({ attributes: { name: 'video 1' } }) + await server.videos.upload({ attributes: { name: 'video 2' } }) - await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) + await server.users.updateMyAvatar({ fixture: 'avatar.png' }) - await server.playlistsCommand.create({ + await server.playlists.create({ attributes: { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, - videoChannelId: server.videoChannel.id, + videoChannelId: server.store.channel.id, thumbnailfile: 'thumbnail.jpg' } }) @@ -87,7 +87,7 @@ describe('Test prune storage scripts', function () { // Lazy load the remote avatar { - const account = await servers[0].accountsCommand.get({ accountName: 'root@localhost:' + servers[1].port }) + const account = await servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port }) await makeGetRequest({ url: servers[0].url, path: account.avatar.path, @@ -96,7 +96,7 @@ describe('Test prune storage scripts', function () { } { - const account = await servers[1].accountsCommand.get({ accountName: 'root@localhost:' + servers[0].port }) + const account = await servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port }) await makeGetRequest({ url: servers[1].url, path: account.avatar.path, @@ -119,7 +119,7 @@ describe('Test prune storage scripts', function () { it('Should create some dirty files', async function () { for (let i = 0; i < 2; i++) { { - const base = servers[0].serversCommand.buildDirectory('videos') + const base = servers[0].servers.buildDirectory('videos') const n1 = buildUUID() + '.mp4' const n2 = buildUUID() + '.webm' @@ -131,7 +131,7 @@ describe('Test prune storage scripts', function () { } { - const base = servers[0].serversCommand.buildDirectory('torrents') + const base = servers[0].servers.buildDirectory('torrents') const n1 = buildUUID() + '-240.torrent' const n2 = buildUUID() + '-480.torrent' @@ -143,7 +143,7 @@ describe('Test prune storage scripts', function () { } { - const base = servers[0].serversCommand.buildDirectory('thumbnails') + const base = servers[0].servers.buildDirectory('thumbnails') const n1 = buildUUID() + '.jpg' const n2 = buildUUID() + '.jpg' @@ -155,7 +155,7 @@ describe('Test prune storage scripts', function () { } { - const base = servers[0].serversCommand.buildDirectory('previews') + const base = servers[0].servers.buildDirectory('previews') const n1 = buildUUID() + '.jpg' const n2 = buildUUID() + '.jpg' @@ -167,7 +167,7 @@ describe('Test prune storage scripts', function () { } { - const base = servers[0].serversCommand.buildDirectory('avatars') + const base = servers[0].servers.buildDirectory('avatars') const n1 = buildUUID() + '.png' const n2 = buildUUID() + '.jpg' @@ -183,7 +183,7 @@ describe('Test prune storage scripts', function () { it('Should run prune storage', async function () { this.timeout(30000) - const env = servers[0].cliCommand.getEnv() + const env = servers[0].cli.getEnv() await CLICommand.exec(`echo y | ${env} npm run prune-storage`) }) diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index d59520783..2df1a1157 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -15,7 +15,7 @@ import { } from '../../../shared/extra-utils' async function testThumbnail (server: ServerInfo, videoId: number | string) { - const video = await server.videosCommand.get({ id: videoId }) + const video = await server.videos.get({ id: videoId }) const requests = [ makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200), @@ -47,22 +47,22 @@ describe('Test regenerate thumbnails script', function () { await doubleFollow(servers[0], servers[1]) { - const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid - video1 = await servers[0].videosCommand.get({ id: videoUUID1 }) + const videoUUID1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid + video1 = await servers[0].videos.get({ id: videoUUID1 }) - thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) + thumbnail1Path = join(servers[0].servers.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) - const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid - video2 = await servers[0].videosCommand.get({ id: videoUUID2 }) + const videoUUID2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid + video2 = await servers[0].videos.get({ id: videoUUID2 }) } { - const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid + const videoUUID = (await servers[1].videos.quickUpload({ name: 'video 3' })).uuid await waitJobs(servers) - remoteVideo = await servers[0].videosCommand.get({ id: videoUUID }) + remoteVideo = await servers[0].videos.get({ id: videoUUID }) - thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) + thumbnailRemotePath = join(servers[0].servers.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) } await writeFile(thumbnail1Path, '') @@ -89,7 +89,7 @@ describe('Test regenerate thumbnails script', function () { it('Should regenerate local thumbnails from the CLI', async function () { this.timeout(15000) - await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`) + await servers[0].cli.execWithEnv(`npm run regenerate-thumbnails`) }) it('Should have generated new thumbnail files', async function () { diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index 5e1e1c2af..e0d6f220a 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts @@ -9,16 +9,16 @@ describe('Test reset password scripts', function () { server = await flushAndRunServer(1) await setAccessTokensToServers([ server ]) - await server.usersCommand.create({ username: 'user_1', password: 'super password' }) + await server.users.create({ username: 'user_1', password: 'super password' }) }) it('Should change the user password from CLI', async function () { this.timeout(60000) - const env = server.cliCommand.getEnv() + const env = server.cli.getEnv() await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`) - await server.loginCommand.login({ user: { username: 'user_1', password: 'coucou' } }) + await server.login.login({ user: { username: 'user_1', password: 'coucou' } }) }) after(async function () { diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index d90b4a64d..d2d196456 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -30,11 +30,11 @@ describe('Test update host scripts', function () { await setAccessTokensToServers([ server ]) // Upload two videos for our needs - const { uuid: video1UUID } = await server.videosCommand.upload() - await server.videosCommand.upload() + const { uuid: video1UUID } = await server.videos.upload() + await server.videos.upload() // Create a user - await server.usersCommand.create({ username: 'toto', password: 'coucou' }) + await server.users.create({ username: 'toto', password: 'coucou' }) // Create channel const videoChannel = { @@ -42,11 +42,11 @@ describe('Test update host scripts', function () { displayName: 'second video channel', description: 'super video channel description' } - await server.channelsCommand.create({ attributes: videoChannel }) + await server.channels.create({ attributes: videoChannel }) // Create comments const text = 'my super first comment' - await server.commentsCommand.createThread({ videoId: video1UUID, text }) + await server.comments.createThread({ videoId: video1UUID, text }) await waitJobs(server) }) @@ -58,11 +58,11 @@ describe('Test update host scripts', function () { // Run server with standard configuration await reRunServer(server) - await server.cliCommand.execWithEnv(`npm run update-host`) + await server.cli.execWithEnv(`npm run update-host`) }) it('Should have updated videos url', async function () { - const { total, data } = await server.videosCommand.list() + const { total, data } = await server.videos.list() expect(total).to.equal(2) for (const video of data) { @@ -70,7 +70,7 @@ describe('Test update host scripts', function () { expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) - const videoDetails = await server.videosCommand.get({ id: video.uuid }) + const videoDetails = await server.videos.get({ id: video.uuid }) expect(videoDetails.trackerUrls[0]).to.include(server.host) expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host) @@ -79,7 +79,7 @@ describe('Test update host scripts', function () { }) it('Should have updated video channels url', async function () { - const { data, total } = await server.channelsCommand.list({ sort: '-name' }) + const { data, total } = await server.channels.list({ sort: '-name' }) expect(total).to.equal(3) for (const channel of data) { @@ -90,7 +90,7 @@ describe('Test update host scripts', function () { }) it('Should have updated accounts url', async function () { - const body = await server.accountsCommand.list() + const body = await server.accounts.list() expect(body.total).to.equal(3) for (const account of body.data) { @@ -104,11 +104,11 @@ describe('Test update host scripts', function () { it('Should have updated torrent hosts', async function () { this.timeout(30000) - const { data } = await server.videosCommand.list() + const { data } = await server.videos.list() expect(data).to.have.lengthOf(2) for (const video of data) { - const videoDetails = await server.videosCommand.get({ id: video.id }) + const videoDetails = await server.videos.get({ id: video.id }) expect(videoDetails.files).to.have.lengthOf(4) -- cgit v1.2.3 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/cli/create-import-video-file-job.ts | 6 +++--- server/tests/cli/create-transcoding-job.ts | 8 ++++---- server/tests/cli/optimize-old-videos.ts | 8 ++++---- server/tests/cli/peertube.ts | 14 +++++++------- server/tests/cli/plugins.ts | 13 ++++++------- server/tests/cli/prune-storage.ts | 14 +++++++------- server/tests/cli/regenerate-thumbnails.ts | 10 +++++----- server/tests/cli/reset-password.ts | 6 +++--- server/tests/cli/update-host.ts | 11 +++++------ 9 files changed, 44 insertions(+), 46 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 26f4bdc8d..e8cd71e09 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' +import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' import { VideoFile } from '@shared/models' const expect = chai.expect @@ -20,7 +20,7 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s describe('Test create import video jobs', function () { this.timeout(60000) - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let video1UUID: string let video2UUID: string @@ -28,7 +28,7 @@ describe('Test create import video jobs', function () { this.timeout(90000) // Run server 2 to have transcoding enabled - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await doubleFollow(servers[0], servers[1]) diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index c9bbab802..53f187f90 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, - ServerInfo, + createMultipleServers, + PeerTubeServer, setAccessTokensToServers, waitJobs } from '../../../shared/extra-utils' @@ -14,7 +14,7 @@ import { const expect = chai.expect describe('Test create transcoding jobs', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] const videosUUID: string[] = [] const config = { @@ -39,7 +39,7 @@ describe('Test create transcoding jobs', function () { this.timeout(60000) // Run server 2 to have transcoding enabled - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await servers[0].config.updateCustomSubConfig({ newConfig: config }) diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index eefc95a6d..53f47a85e 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -6,9 +6,9 @@ import { join } from 'path' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, generateHighBitrateVideo, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, wait, waitJobs @@ -20,13 +20,13 @@ import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants' const expect = chai.expect describe('Test optimize old videos', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] before(async function () { this.timeout(200000) // Run server 2 to have transcoding enabled - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await doubleFollow(servers[0], servers[1]) diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index a83aa7724..f19b6ae22 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -8,16 +8,16 @@ import { cleanupTests, CLICommand, doubleFollow, - flushAndRunServer, + createSingleServer, ImportsCommand, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, testHelloWorldRegisteredSettings, waitJobs } from '../../../shared/extra-utils' describe('Test CLI wrapper', function () { - let server: ServerInfo + let server: PeerTubeServer let userAccessToken: string let cliCommand: CLICommand @@ -27,7 +27,7 @@ describe('Test CLI wrapper', function () { before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) await server.users.create({ username: 'user_1', password: 'super_password' }) @@ -210,14 +210,14 @@ describe('Test CLI wrapper', function () { }) describe('Manage video redundancies', function () { - let anotherServer: ServerInfo + let anotherServer: PeerTubeServer let video1Server2: number - let servers: ServerInfo[] + let servers: PeerTubeServer[] before(async function () { this.timeout(120000) - anotherServer = await flushAndRunServer(2) + anotherServer = await createSingleServer(2) await setAccessTokensToServers([ anotherServer ]) await doubleFollow(server, anotherServer) diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index 178a7a2d9..42651d79c 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -4,21 +4,20 @@ import 'mocha' import { expect } from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, killallServers, PluginsCommand, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers } from '../../../shared/extra-utils' describe('Test plugin scripts', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) }) @@ -40,7 +39,7 @@ describe('Test plugin scripts', function () { this.timeout(30000) await killallServers([ server ]) - await reRunServer(server) + await server.run() const config = await server.config.getConfig() @@ -63,7 +62,7 @@ describe('Test plugin scripts', function () { this.timeout(30000) await killallServers([ server ]) - await reRunServer(server) + await server.run() const config = await server.config.getConfig() diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 9912a36e0..5bf86462b 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -10,10 +10,10 @@ import { cleanupTests, CLICommand, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, killallServers, makeGetRequest, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, wait, @@ -23,13 +23,13 @@ import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect -async function countFiles (server: ServerInfo, directory: string) { +async function countFiles (server: PeerTubeServer, directory: string) { const files = await readdir(server.servers.buildDirectory(directory)) return files.length } -async function assertNotExists (server: ServerInfo, directory: string, substring: string) { +async function assertNotExists (server: PeerTubeServer, directory: string, substring: string) { const files = await readdir(server.servers.buildDirectory(directory)) for (const f of files) { @@ -37,7 +37,7 @@ async function assertNotExists (server: ServerInfo, directory: string, substring } } -async function assertCountAreOkay (servers: ServerInfo[]) { +async function assertCountAreOkay (servers: PeerTubeServer[]) { for (const server of servers) { const videosCount = await countFiles(server, 'videos') expect(videosCount).to.equal(8) @@ -57,13 +57,13 @@ async function assertCountAreOkay (servers: ServerInfo[]) { } describe('Test prune storage scripts', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] const badNames: { [directory: string]: string[] } = {} before(async function () { this.timeout(120000) - servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: true } }) + servers = await createMultipleServers(2, { transcoding: { enabled: true } }) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index 2df1a1157..d532a5c2b 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -7,14 +7,14 @@ import { Video } from '@shared/models' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, makeRawRequest, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, waitJobs } from '../../../shared/extra-utils' -async function testThumbnail (server: ServerInfo, videoId: number | string) { +async function testThumbnail (server: PeerTubeServer, videoId: number | string) { const video = await server.videos.get({ id: videoId }) const requests = [ @@ -29,7 +29,7 @@ async function testThumbnail (server: ServerInfo, videoId: number | string) { } describe('Test regenerate thumbnails script', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let video1: Video let video2: Video @@ -41,7 +41,7 @@ describe('Test regenerate thumbnails script', function () { 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/cli/reset-password.ts b/server/tests/cli/reset-password.ts index e0d6f220a..4a02db35d 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts @@ -1,12 +1,12 @@ import 'mocha' -import { cleanupTests, CLICommand, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../shared/extra-utils' +import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '../../../shared/extra-utils' describe('Test reset password scripts', 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.users.create({ username: 'user_1', password: 'super password' }) diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index d2d196456..fcbcb55ba 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -4,18 +4,17 @@ import 'mocha' import { expect } from 'chai' import { cleanupTests, - flushAndRunServer, + createSingleServer, killallServers, makeActivityPubGetRequest, parseTorrentVideo, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' describe('Test update host scripts', function () { - let server: ServerInfo + let server: PeerTubeServer before(async function () { this.timeout(60000) @@ -26,7 +25,7 @@ describe('Test update host scripts', function () { } } // Run server 2 to have transcoding enabled - server = await flushAndRunServer(2, overrideConfig) + server = await createSingleServer(2, overrideConfig) await setAccessTokensToServers([ server ]) // Upload two videos for our needs @@ -56,7 +55,7 @@ describe('Test update host scripts', function () { await killallServers([ server ]) // Run server with standard configuration - await reRunServer(server) + await server.run() await server.cli.execWithEnv(`npm run update-host`) }) -- cgit v1.2.3 From 59bbcced37005dd511daca9bd58ae2998cb931b1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:19:16 +0200 Subject: Centralize test URLs --- server/tests/cli/peertube.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index f19b6ae22..f2a984962 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -7,9 +7,9 @@ import { buildAbsoluteFixturePath, cleanupTests, CLICommand, - doubleFollow, createSingleServer, - ImportsCommand, + doubleFollow, + FIXTURE_URLS, PeerTubeServer, setAccessTokensToServers, testHelloWorldRegisteredSettings, @@ -117,7 +117,7 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} --channel-name user_channel` + const params = `--target-url ${FIXTURE_URLS.youtube} --channel-name user_channel` await cliCommand.execWithEnv(`${cmd} import ${params}`) }) @@ -148,7 +148,7 @@ describe('Test CLI wrapper', function () { this.timeout(60000) - const params = `--target-url ${ImportsCommand.getYoutubeVideoUrl()} ` + + const params = `--target-url ${FIXTURE_URLS.youtube} ` + `--channel-name user_channel --video-name toto --nsfw --support support` await cliCommand.execWithEnv(`${cmd} import ${params}`) -- cgit v1.2.3 From c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 10:42:24 +0200 Subject: Refactor requests --- server/tests/cli/prune-storage.ts | 6 +++--- server/tests/cli/regenerate-thumbnails.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 5bf86462b..2bd4a466b 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -5,7 +5,7 @@ import * as chai from 'chai' import { createFile, readdir } from 'fs-extra' import { join } from 'path' import { buildUUID } from '@server/helpers/uuid' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { cleanupTests, CLICommand, @@ -91,7 +91,7 @@ describe('Test prune storage scripts', function () { await makeGetRequest({ url: servers[0].url, path: account.avatar.path, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) } @@ -100,7 +100,7 @@ describe('Test prune storage scripts', function () { await makeGetRequest({ url: servers[1].url, path: account.avatar.path, - statusCodeExpected: HttpStatusCode.OK_200 + expectedStatus: HttpStatusCode.OK_200 }) } diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index d532a5c2b..595d842ef 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' import { writeFile } from 'fs-extra' import { basename, join } from 'path' -import { HttpStatusCode } from '@shared/core-utils' +import { HttpStatusCode } from '@shared/models' import { Video } from '@shared/models' import { cleanupTests, -- cgit v1.2.3 From 4c7e60bc17ee5830399bac4aa273356903421b4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 14:27:30 +0200 Subject: Reorganize imports --- server/tests/cli/create-import-video-file-job.ts | 2 +- server/tests/cli/create-transcoding-job.ts | 2 +- server/tests/cli/optimize-old-videos.ts | 2 +- server/tests/cli/plugins.ts | 2 +- server/tests/cli/prune-storage.ts | 5 ++--- server/tests/cli/regenerate-thumbnails.ts | 5 ++--- 6 files changed, 8 insertions(+), 10 deletions(-) (limited to 'server/tests/cli') diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index e8cd71e09..bddcff5e7 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' +import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' import { VideoFile } from '@shared/models' const expect = chai.expect diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index 53f187f90..df787ccdc 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -4,8 +4,8 @@ import 'mocha' import * as chai from 'chai' import { cleanupTests, - doubleFollow, createMultipleServers, + doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index 53f47a85e..685b3b7b8 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { join } from 'path' import { cleanupTests, - doubleFollow, createMultipleServers, + doubleFollow, generateHighBitrateVideo, PeerTubeServer, setAccessTokensToServers, diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts index 42651d79c..07c78cc89 100644 --- a/server/tests/cli/plugins.ts +++ b/server/tests/cli/plugins.ts @@ -6,8 +6,8 @@ import { cleanupTests, createSingleServer, killallServers, - PluginsCommand, PeerTubeServer, + PluginsCommand, setAccessTokensToServers } from '../../../shared/extra-utils' diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 2bd4a466b..954a87833 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts @@ -5,12 +5,11 @@ import * as chai from 'chai' import { createFile, readdir } from 'fs-extra' import { join } from 'path' import { buildUUID } from '@server/helpers/uuid' -import { HttpStatusCode } from '@shared/models' import { cleanupTests, CLICommand, - doubleFollow, createMultipleServers, + doubleFollow, killallServers, makeGetRequest, PeerTubeServer, @@ -19,7 +18,7 @@ import { wait, waitJobs } from '@shared/extra-utils' -import { VideoPlaylistPrivacy } from '@shared/models' +import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index 595d842ef..780c9b4bd 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -2,12 +2,11 @@ import 'mocha' import { expect } from 'chai' import { writeFile } from 'fs-extra' import { basename, join } from 'path' -import { HttpStatusCode } from '@shared/models' -import { Video } from '@shared/models' +import { HttpStatusCode, Video } from '@shared/models' import { cleanupTests, - doubleFollow, createMultipleServers, + doubleFollow, makeRawRequest, PeerTubeServer, setAccessTokensToServers, -- cgit v1.2.3