]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/resumable-upload.ts
Fix redundancy remove on host redundancy update
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / resumable-upload.ts
index 13e47c85e71d32648d478ba5a6a443099e1eeae8..857859fd3a95c4209bd361b052871caf6dea3d44 100644 (file)
@@ -146,8 +146,7 @@ describe('Test resumable upload', function () {
     })
 
     it('Should not accept more chunks than expected', async function () {
-      const size = 100
-      const uploadId = await prepareUpload(size)
+      const uploadId = await prepareUpload(100)
 
       await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409 })
       await checkFileSize(uploadId, 0)
@@ -156,8 +155,14 @@ 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(1500)
 
-      await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentLength: 1000 })
-      await checkFileSize(uploadId, 0)
+      // Content length check seems to have changed in v16
+      if (process.version.startsWith('v16')) {
+        await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 })
+        await checkFileSize(uploadId, 1000)
+      } else {
+        await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentLength: 1000 })
+        await checkFileSize(uploadId, 0)
+      }
     })
 
     it('Should not accept more chunks than expected with an invalid content length', async function () {
@@ -165,8 +170,13 @@ describe('Test resumable upload', function () {
 
       const size = 1000
 
-      const contentRangeBuilder = start => `bytes ${start}-${start + size - 1}/${size}`
-      await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentRangeBuilder, contentLength: size })
+      // Content length check seems to have changed in v16
+      const expectedStatus = process.version.startsWith('v16')
+        ? HttpStatusCode.CONFLICT_409
+        : HttpStatusCode.BAD_REQUEST_400
+
+      const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}`
+      await sendChunks({ pathUploadId: uploadId, expectedStatus, contentRangeBuilder, contentLength: size })
       await checkFileSize(uploadId, 0)
     })
   })