aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/shared/live.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-17 11:58:15 +0100
committerChocobozzz <me@florianbigard.com>2021-12-17 12:24:03 +0100
commitc55e3d7227fe1453869e309025996b9d75256d5d (patch)
tree08e9b0ca210d75c82c8606fef0852eca020e8e0e /server/tests/shared/live.ts
parentbf54587a3e2ad9c2c186828f2a5682b91ee2cc00 (diff)
downloadPeerTube-c55e3d7227fe1453869e309025996b9d75256d5d.tar.gz
PeerTube-c55e3d7227fe1453869e309025996b9d75256d5d.tar.zst
PeerTube-c55e3d7227fe1453869e309025996b9d75256d5d.zip
Move test functions outside extra-utils
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}