X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fvideos%2Fresumable-upload.ts;h=642c115d030c5be820c17af76f771c8bf27d5337;hb=7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0;hp=af9221c43b94749f507dda9323b58f2d84162fc2;hpb=ad35265d743e621d86f3f0796dd9d8795c599dca;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index af9221c43..642c115d0 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts @@ -7,18 +7,15 @@ import { join } from 'path' import { HttpStatusCode } from '@shared/core-utils' import { buildAbsoluteFixturePath, - buildServerDirectory, + cleanupTests, flushAndRunServer, - getMyUserInformation, prepareResumableUpload, - sendDebugCommand, sendResumableChunks, ServerInfo, setAccessTokensToServers, - setDefaultVideoChannel, - updateUser + setDefaultVideoChannel } from '@shared/extra-utils' -import { MyUser, VideoPrivacy } from '@shared/models' +import { VideoPrivacy } from '@shared/models' const expect = chai.expect @@ -82,7 +79,7 @@ describe('Test resumable upload', function () { const uploadId = uploadIdArg.replace(/^upload_id=/, '') const subPath = join('tmp', 'resumable-uploads', uploadId) - const filePath = buildServerDirectory(server, subPath) + const filePath = server.serversCommand.buildDirectory(subPath) const exists = await pathExists(filePath) if (expectedSize === null) { @@ -97,7 +94,7 @@ describe('Test resumable upload', function () { async function countResumableUploads () { const subPath = join('tmp', 'resumable-uploads') - const filePath = buildServerDirectory(server, subPath) + const filePath = server.serversCommand.buildDirectory(subPath) const files = await readdir(filePath) return files.length @@ -110,15 +107,10 @@ describe('Test resumable upload', function () { await setAccessTokensToServers([ server ]) await setDefaultVideoChannel([ server ]) - const res = await getMyUserInformation(server.url, server.accessToken) - rootId = (res.body as MyUser).id + const body = await server.usersCommand.getMyInfo() + rootId = body.id - await updateUser({ - url: server.url, - userId: rootId, - accessToken: server.accessToken, - videoQuota: 10_000_000 - }) + await server.usersCommand.update({ userId: rootId, videoQuota: 10_000_000 }) }) describe('Directory cleaning', function () { @@ -137,13 +129,13 @@ describe('Test resumable upload', function () { }) it('Should not delete recent uploads', async function () { - await sendDebugCommand(server.url, server.accessToken, { command: 'remove-dandling-resumable-uploads' }) + await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) expect(await countResumableUploads()).to.equal(2) }) it('Should delete old uploads', async function () { - await sendDebugCommand(server.url, server.accessToken, { command: 'remove-dandling-resumable-uploads' }) + await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) expect(await countResumableUploads()).to.equal(0) }) @@ -184,4 +176,7 @@ describe('Test resumable upload', function () { }) }) + after(async function () { + await cleanupTests([ server ]) + }) })