Fix resumable tests

pull/6003/head
Chocobozzz 2023-10-11 16:17:11 +02:00
parent 7243393272
commit 5bd42bbca7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 4 additions and 14 deletions

View File

@ -183,14 +183,9 @@ describe('Test resumable upload', function () {
it('Should not accept more chunks than expected with an invalid content length/content range', async function () { it('Should not accept more chunks than expected with an invalid content length/content range', async function () {
const uploadId = await prepareUpload({ size: 1500 }) const uploadId = await prepareUpload({ size: 1500 })
// Content length check can be different depending on the node version await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 })
try {
await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentLength: 1000 }) await checkFileSize(uploadId, 0)
await checkFileSize(uploadId, 0)
} catch {
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 () { it('Should not accept more chunks than expected with an invalid content length', async function () {
@ -198,13 +193,8 @@ describe('Test resumable upload', function () {
const size = 1000 const size = 1000
// 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}` const contentRangeBuilder = (start: number) => `bytes ${start}-${start + size - 1}/${size}`
await sendChunks({ pathUploadId: uploadId, expectedStatus, contentRangeBuilder, contentLength: size }) await sendChunks({ pathUploadId: uploadId, expectedStatus: HttpStatusCode.CONFLICT_409, contentRangeBuilder, contentLength: size })
await checkFileSize(uploadId, 0) await checkFileSize(uploadId, 0)
}) })