import * as chai from 'chai'
import { pathExists, readdir, stat } from 'fs-extra'
import { join } from 'path'
-import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
cleanupTests,
setAccessTokensToServers,
setDefaultVideoChannel
} from '@shared/extra-utils'
-import { VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
const expect = chai.expect
})
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)
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 () {
const size = 1000
- const contentRangeBuilder = start => `bytes ${start}-${start + size - 1}/${size}`
- await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.BAD_REQUEST_400, contentRangeBuilder, contentLength: size })
+ const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}`
+ await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentRangeBuilder, contentLength: size })
await checkFileSize(uploadId, 0)
})
})