aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/shared/live.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/shared/live.ts')
-rw-r--r--server/tests/shared/live.ts41
1 files changed, 41 insertions, 0 deletions
diff --git a/server/tests/shared/live.ts b/server/tests/shared/live.ts
new file mode 100644
index 000000000..72e3e27f6
--- /dev/null
+++ b/server/tests/shared/live.ts
@@ -0,0 +1,41 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra'
5import { join } from 'path'
6import { PeerTubeServer } from '@shared/server-commands'
7
8async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) {
9 const basePath = server.servers.buildDirectory('streaming-playlists')
10 const hlsPath = join(basePath, 'hls', videoUUID)
11
12 if (resolutions.length === 0) {
13 const result = await pathExists(hlsPath)
14 expect(result).to.be.false
15
16 return
17 }
18
19 const files = await readdir(hlsPath)
20
21 // fragmented file and playlist per resolution + master playlist + segments sha256 json file
22 expect(files).to.have.lengthOf(resolutions.length * 2 + 2)
23
24 for (const resolution of resolutions) {
25 const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`))
26 expect(fragmentedFile).to.exist
27
28 const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`))
29 expect(playlistFile).to.exist
30 }
31
32 const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8'))
33 expect(masterPlaylistFile).to.exist
34
35 const shaFile = files.find(f => f.endsWith('-segments-sha256.json'))
36 expect(shaFile).to.exist
37}
38
39export {
40 checkLiveCleanupAfterSave
41}