]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/create-import-video-file-job.ts
Update angular
[github/Chocobozzz/PeerTube.git] / server / tests / cli / create-import-video-file-job.ts
index a4aa5f69984ebd6a3219d2d88f75ed77da11126e..edd727967c7818f1d290de2e88f79324e21bf221 100644 (file)
@@ -1,7 +1,7 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import { expect } from 'chai'
-import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { areMockObjectStorageTestsDisabled } from '@shared/core-utils'
 import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'
 import {
   cleanupTests,
@@ -25,25 +25,27 @@ function assertVideoProperties (video: VideoFile, resolution: number, extname: s
   if (size) expect(video.size).to.equal(size)
 }
 
-async function checkFiles (video: VideoDetails, objectStorage: boolean) {
+async function checkFiles (video: VideoDetails, objectStorage: ObjectStorageCommand) {
   for (const file of video.files) {
-    if (objectStorage) expectStartWith(file.fileUrl, ObjectStorageCommand.getWebTorrentBaseUrl())
+    if (objectStorage) expectStartWith(file.fileUrl, objectStorage.getMockWebVideosBaseUrl())
 
     await makeRawRequest({ url: file.fileUrl, expectedStatus: HttpStatusCode.OK_200 })
   }
 }
 
-function runTests (objectStorage: boolean) {
+function runTests (enableObjectStorage: boolean) {
   let video1ShortId: string
   let video2UUID: string
 
   let servers: PeerTubeServer[] = []
 
+  const objectStorage = new ObjectStorageCommand()
+
   before(async function () {
     this.timeout(90000)
 
-    const config = objectStorage
-      ? ObjectStorageCommand.getDefaultConfig()
+    const config = enableObjectStorage
+      ? objectStorage.getDefaultMockConfig()
       : {}
 
     // Run server 2 to have transcoding enabled
@@ -52,7 +54,7 @@ function runTests (objectStorage: boolean) {
 
     await doubleFollow(servers[0], servers[1])
 
-    if (objectStorage) await ObjectStorageCommand.prepareDefaultBuckets()
+    if (enableObjectStorage) await objectStorage.prepareDefaultMockBuckets()
 
     // Upload two videos for our needs
     {
@@ -73,7 +75,7 @@ function runTests (objectStorage: boolean) {
   })
 
   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 ${video1ShortId} -i server/tests/fixtures/video_short-480.webm`
+    const command = `npm run create-import-video-file-job -- -v ${video1ShortId} -i server/tests/fixtures/video_short_480.webm`
     await servers[0].cli.execWithEnv(command)
 
     await waitJobs(servers)
@@ -90,7 +92,7 @@ function runTests (objectStorage: boolean) {
       assertVideoProperties(originalVideo, 720, 'webm', 218910)
       assertVideoProperties(transcodedVideo, 480, 'webm', 69217)
 
-      await checkFiles(videoDetails, objectStorage)
+      await checkFiles(videoDetails, enableObjectStorage && objectStorage)
     }
   })
 
@@ -114,7 +116,7 @@ function runTests (objectStorage: boolean) {
       assertVideoProperties(transcodedVideo320, 360, 'mp4')
       assertVideoProperties(transcodedVideo240, 240, 'mp4')
 
-      await checkFiles(videoDetails, objectStorage)
+      await checkFiles(videoDetails, enableObjectStorage && objectStorage)
     }
   })
 
@@ -136,7 +138,7 @@ function runTests (objectStorage: boolean) {
       assertVideoProperties(video720, 720, 'webm', 942961)
       assertVideoProperties(video480, 480, 'webm', 69217)
 
-      await checkFiles(videoDetails, objectStorage)
+      await checkFiles(videoDetails, enableObjectStorage && objectStorage)
     }
   })
 
@@ -146,6 +148,8 @@ function runTests (objectStorage: boolean) {
   })
 
   after(async function () {
+    await objectStorage.cleanupMock()
+
     await cleanupTests(servers)
   })
 }
@@ -157,7 +161,7 @@ describe('Test create import video jobs', function () {
   })
 
   describe('On object storage', function () {
-    if (areObjectStorageTestsDisabled()) return
+    if (areMockObjectStorageTestsDisabled()) return
 
     runTests(true)
   })