diff options
Diffstat (limited to 'server/tests/shared/live.ts')
-rw-r--r-- | server/tests/shared/live.ts | 41 |
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 | |||
3 | import { expect } from 'chai' | ||
4 | import { pathExists, readdir } from 'fs-extra' | ||
5 | import { join } from 'path' | ||
6 | import { PeerTubeServer } from '@shared/server-commands' | ||
7 | |||
8 | async 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 | |||
39 | export { | ||
40 | checkLiveCleanupAfterSave | ||
41 | } | ||