]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/videos/resumable-upload.ts
Introduce user command
[github/Chocobozzz/PeerTube.git] / server / tests / api / videos / resumable-upload.ts
index af9221c43b94749f507dda9323b58f2d84162fc2..642c115d030c5be820c17af76f771c8bf27d5337 100644 (file)
@@ -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 ])
+  })
 })