]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/resumable-upload.ts
Enable external plugins to test the PR
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / resumable-upload.ts
index 9936d5467dcf0b8270f01191aba7557716750e32..2fbefb39282d7ce372c20068a9d1354f7d98344e 100644 (file)
@@ -1,6 +1,6 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import * as chai from 'chai'
+import { expect } from 'chai'
 import { pathExists, readdir, stat } from 'fs-extra'
 import { join } from 'path'
 import { buildAbsoluteFixturePath } from '@shared/core-utils'
@@ -8,8 +8,6 @@ import { sha1 } from '@shared/extra-utils'
 import { HttpStatusCode, VideoPrivacy } from '@shared/models'
 import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'
 
-const expect = chai.expect
-
 // Most classic resumable upload tests are done in other test suites
 
 describe('Test resumable upload', function () {
@@ -81,7 +79,7 @@ describe('Test resumable upload', function () {
   async function checkFileSize (uploadIdArg: string, expectedSize: number | null) {
     const uploadId = uploadIdArg.replace(/^upload_id=/, '')
 
-    const subPath = join('tmp', 'resumable-uploads', uploadId)
+    const subPath = join('tmp', 'resumable-uploads', `${rootId}-${uploadId}.mp4`)
     const filePath = server.servers.buildDirectory(subPath)
     const exists = await pathExists(filePath)
 
@@ -171,11 +169,11 @@ describe('Test resumable upload', function () {
     it('Should not accept more chunks than expected with an invalid content length/content range', async function () {
       const uploadId = await prepareUpload({ size: 1500 })
 
-      // Content length check seems to have changed in v16
-      if (process.version.startsWith('v16')) {
+      // Content length check can be different depending on the node version
+      try {
         await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 })
-        await checkFileSize(uploadId, 1000)
-      } else {
+        await checkFileSize(uploadId, 0)
+      } catch {
         await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentLength: 1000 })
         await checkFileSize(uploadId, 0)
       }
@@ -263,7 +261,7 @@ describe('Test resumable upload', function () {
         pathUploadId: uploadId,
         token: server.accessToken,
         digestBuilder: () => 'sha=' + 'a'.repeat(40),
-        expectedStatus: 460
+        expectedStatus: 460 as any
       })
     })