]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/prune-storage.ts
render markdown and plainify descriptions on previews
[github/Chocobozzz/PeerTube.git] / server / tests / cli / prune-storage.ts
index 144e67c44e9214923fc9e399fe36db545d439965..591ed217fa46094193416c31e399c4ddcb58d847 100644 (file)
@@ -1,4 +1,4 @@
-/* tslint:disable:no-unused-expression */
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
 import * as chai from 'chai'
@@ -11,29 +11,31 @@ import {
   execCLI,
   flushAndRunMultipleServers,
   getAccount,
-  getEnvCli, makeGetRequest, makeRawRequest,
+  getEnvCli,
+  makeGetRequest,
   ServerInfo,
-  setAccessTokensToServers, setDefaultVideoChannel,
+  setAccessTokensToServers,
+  setDefaultVideoChannel,
   updateMyAvatar,
   uploadVideo,
   wait
 } from '../../../shared/extra-utils'
 import { Account, VideoPlaylistPrivacy } from '../../../shared/models'
 import { createFile, readdir } from 'fs-extra'
-import * as uuidv4 from 'uuid/v4'
+import { v4 as uuidv4 } from 'uuid'
 import { join } from 'path'
-import * as request from 'supertest'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 
 const expect = chai.expect
 
 async function countFiles (internalServerNumber: number, directory: string) {
-  const files = await readdir(buildServerDirectory(internalServerNumber, directory))
+  const files = await readdir(buildServerDirectory({ internalServerNumber }, directory))
 
   return files.length
 }
 
 async function assertNotExists (internalServerNumber: number, directory: string, substring: string) {
-  const files = await readdir(buildServerDirectory(internalServerNumber, directory))
+  const files = await readdir(buildServerDirectory({ internalServerNumber }, directory))
 
   for (const f of files) {
     expect(f).to.not.contain(substring)
@@ -61,7 +63,7 @@ async function assertCountAreOkay (servers: ServerInfo[]) {
 
 describe('Test prune storage scripts', function () {
   let servers: ServerInfo[]
-  const badNames: { [ directory: string ]: string[] } = {}
+  const badNames: { [directory: string]: string[] } = {}
 
   before(async function () {
     this.timeout(120000)
@@ -92,22 +94,22 @@ describe('Test prune storage scripts', function () {
 
     // Lazy load the remote avatar
     {
-      const res = await getAccount(servers[ 0 ].url, 'root@localhost:' + servers[ 1 ].port)
+      const res = await getAccount(servers[0].url, 'root@localhost:' + servers[1].port)
       const account: Account = res.body
       await makeGetRequest({
-        url: servers[ 0 ].url,
+        url: servers[0].url,
         path: account.avatar.path,
-        statusCodeExpected: 200
+        statusCodeExpected: HttpStatusCode.OK_200
       })
     }
 
     {
-      const res = await getAccount(servers[ 1 ].url, 'root@localhost:' + servers[ 0 ].port)
+      const res = await getAccount(servers[1].url, 'root@localhost:' + servers[0].port)
       const account: Account = res.body
       await makeGetRequest({
-        url: servers[ 1 ].url,
+        url: servers[1].url,
         path: account.avatar.path,
-        statusCodeExpected: 200
+        statusCodeExpected: HttpStatusCode.OK_200
       })
     }
 
@@ -123,7 +125,7 @@ describe('Test prune storage scripts', function () {
   it('Should create some dirty files', async function () {
     for (let i = 0; i < 2; i++) {
       {
-        const base = buildServerDirectory(servers[0].internalServerNumber, 'videos')
+        const base = buildServerDirectory(servers[0], 'videos')
 
         const n1 = uuidv4() + '.mp4'
         const n2 = uuidv4() + '.webm'
@@ -135,7 +137,7 @@ describe('Test prune storage scripts', function () {
       }
 
       {
-        const base = buildServerDirectory(servers[0].internalServerNumber, 'torrents')
+        const base = buildServerDirectory(servers[0], 'torrents')
 
         const n1 = uuidv4() + '-240.torrent'
         const n2 = uuidv4() + '-480.torrent'
@@ -147,7 +149,7 @@ describe('Test prune storage scripts', function () {
       }
 
       {
-        const base = buildServerDirectory(servers[0].internalServerNumber, 'thumbnails')
+        const base = buildServerDirectory(servers[0], 'thumbnails')
 
         const n1 = uuidv4() + '.jpg'
         const n2 = uuidv4() + '.jpg'
@@ -159,7 +161,7 @@ describe('Test prune storage scripts', function () {
       }
 
       {
-        const base = buildServerDirectory(servers[0].internalServerNumber, 'previews')
+        const base = buildServerDirectory(servers[0], 'previews')
 
         const n1 = uuidv4() + '.jpg'
         const n2 = uuidv4() + '.jpg'
@@ -171,7 +173,7 @@ describe('Test prune storage scripts', function () {
       }
 
       {
-        const base = buildServerDirectory(servers[0].internalServerNumber, 'avatars')
+        const base = buildServerDirectory(servers[0], 'avatars')
 
         const n1 = uuidv4() + '.png'
         const n2 = uuidv4() + '.jpg'