]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/cli/prune-storage.ts
Relax bitrate/fps test
[github/Chocobozzz/PeerTube.git] / server / tests / cli / prune-storage.ts
index 2bd4a466b8a1d448f3a31fd84c30b566db1fb38c..a89e17e3c3a3f139f24965f9a26539bdeea83df0 100644 (file)
@@ -1,27 +1,23 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
-import 'mocha'
-import * as chai from 'chai'
+import { expect } from 'chai'
 import { createFile, readdir } from 'fs-extra'
 import { join } from 'path'
-import { buildUUID } from '@server/helpers/uuid'
-import { HttpStatusCode } from '@shared/models'
+import { wait } from '@shared/core-utils'
+import { buildUUID } from '@shared/extra-utils'
+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
 import {
   cleanupTests,
   CLICommand,
-  doubleFollow,
   createMultipleServers,
+  doubleFollow,
   killallServers,
   makeGetRequest,
   PeerTubeServer,
   setAccessTokensToServers,
   setDefaultVideoChannel,
-  wait,
   waitJobs
-} from '@shared/extra-utils'
-import { VideoPlaylistPrivacy } from '@shared/models'
-
-const expect = chai.expect
+} from '@shared/server-commands'
 
 async function countFiles (server: PeerTubeServer, directory: string) {
   const files = await readdir(server.servers.buildDirectory(directory))
@@ -52,7 +48,10 @@ async function assertCountAreOkay (servers: PeerTubeServer[]) {
     expect(thumbnailsCount).to.equal(6)
 
     const avatarsCount = await countFiles(server, 'avatars')
-    expect(avatarsCount).to.equal(2)
+    expect(avatarsCount).to.equal(4)
+
+    const hlsRootCount = await countFiles(server, 'streaming-playlists/hls')
+    expect(hlsRootCount).to.equal(2)
   }
 }
 
@@ -85,23 +84,28 @@ describe('Test prune storage scripts', function () {
 
     await doubleFollow(servers[0], servers[1])
 
-    // Lazy load the remote avatar
+    // Lazy load the remote avatars
     {
       const account = await servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port })
-      await makeGetRequest({
-        url: servers[0].url,
-        path: account.avatar.path,
-        expectedStatus: HttpStatusCode.OK_200
-      })
+
+      for (const avatar of account.avatars) {
+        await makeGetRequest({
+          url: servers[0].url,
+          path: avatar.path,
+          expectedStatus: HttpStatusCode.OK_200
+        })
+      }
     }
 
     {
       const account = await servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port })
-      await makeGetRequest({
-        url: servers[1].url,
-        path: account.avatar.path,
-        expectedStatus: HttpStatusCode.OK_200
-      })
+      for (const avatar of account.avatars) {
+        await makeGetRequest({
+          url: servers[1].url,
+          path: avatar.path,
+          expectedStatus: HttpStatusCode.OK_200
+        })
+      }
     }
 
     await wait(1000)
@@ -177,6 +181,15 @@ describe('Test prune storage scripts', function () {
 
         badNames['avatars'] = [ n1, n2 ]
       }
+
+      {
+        const directory = join('streaming-playlists', 'hls')
+        const base = servers[0].servers.buildDirectory(directory)
+
+        const n1 = buildUUID()
+        await createFile(join(base, n1))
+        badNames[directory] = [ n1 ]
+      }
     }
   })