]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/optimize-old-videos.ts
Introduce server commands
[github/Chocobozzz/PeerTube.git] / server / tests / cli / optimize-old-videos.ts
index e2e13598fcf92813d4766ec4df958c50e4b211b5..e369a33058a909d3d52a8611b2ec120d4083876d 100644 (file)
@@ -2,17 +2,14 @@
 
 import 'mocha'
 import * as chai from 'chai'
-import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos'
+import { join } from 'path'
 import {
   cleanupTests,
   doubleFollow,
-  execCLI,
   flushAndRunMultipleServers,
   generateHighBitrateVideo,
-  getEnvCli,
   getVideo,
   getVideosList,
-  root,
   ServerInfo,
   setAccessTokensToServers,
   uploadVideo,
@@ -20,18 +17,14 @@ import {
   wait
 } from '../../../shared/extra-utils'
 import { waitJobs } from '../../../shared/extra-utils/server/jobs'
-import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils'
+import { getMaxBitrate, Video, VideoDetails, VideoResolution } from '../../../shared/models/videos'
+import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffprobe-utils'
 import { VIDEO_TRANSCODING_FPS } from '../../initializers/constants'
-import { join } from 'path'
 
 const expect = chai.expect
 
 describe('Test optimize old videos', function () {
   let servers: ServerInfo[] = []
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
-  let video1UUID: string
-  // eslint-disable-next-line @typescript-eslint/no-unused-vars
-  let video2UUID: string
 
   before(async function () {
     this.timeout(200000)
@@ -52,10 +45,8 @@ describe('Test optimize old videos', function () {
     }
 
     // Upload two videos for our needs
-    const res1 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video1', fixture: tempFixturePath })
-    video1UUID = res1.body.video.uuid
-    const res2 = await uploadVideo(servers[0].url, servers[0].accessToken, { name: 'video2', fixture: tempFixturePath })
-    video2UUID = res2.body.video.uuid
+    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 waitJobs(servers)
   })
@@ -79,9 +70,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) {
@@ -106,7 +95,7 @@ describe('Test optimize old videos', function () {
 
         expect(file.size).to.be.below(8000000)
 
-        const path = join(root(), 'test' + servers[0].internalServerNumber, '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)