diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-22 14:28:03 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-07-26 11:29:31 +0200 |
commit | 83903cb65d531a6b6b91715387493ba8312b264d (patch) | |
tree | fd172e26a483331e74f15a062743a9d40d4016d3 /server/tests/api/videos/video-hls.ts | |
parent | c4fa01f7c45b66b112ebd08abce744b7c4041feb (diff) | |
download | PeerTube-83903cb65d531a6b6b91715387493ba8312b264d.tar.gz PeerTube-83903cb65d531a6b6b91715387493ba8312b264d.tar.zst PeerTube-83903cb65d531a6b6b91715387493ba8312b264d.zip |
Generate random uuid for video files
Diffstat (limited to 'server/tests/api/videos/video-hls.ts')
-rw-r--r-- | server/tests/api/videos/video-hls.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 7845f7334..921d7ce64 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -19,6 +19,8 @@ import { | |||
19 | } from '@shared/extra-utils' | 19 | } from '@shared/extra-utils' |
20 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' | 20 | import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models' |
21 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' | 21 | import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' |
22 | import { uuidRegex } from '@shared/core-utils' | ||
23 | import { basename } from 'path/posix' | ||
22 | 24 | ||
23 | const expect = chai.expect | 25 | const expect = chai.expect |
24 | 26 | ||
@@ -38,14 +40,17 @@ async function checkHlsPlaylist (servers: PeerTubeServer[], videoUUID: string, h | |||
38 | if (hlsOnly) expect(videoDetails.files).to.have.lengthOf(0) | 40 | if (hlsOnly) expect(videoDetails.files).to.have.lengthOf(0) |
39 | else expect(videoDetails.files).to.have.lengthOf(resolutions.length) | 41 | else expect(videoDetails.files).to.have.lengthOf(resolutions.length) |
40 | 42 | ||
43 | // Check JSON files | ||
41 | for (const resolution of resolutions) { | 44 | for (const resolution of resolutions) { |
42 | const file = hlsFiles.find(f => f.resolution.id === resolution) | 45 | const file = hlsFiles.find(f => f.resolution.id === resolution) |
43 | expect(file).to.not.be.undefined | 46 | expect(file).to.not.be.undefined |
44 | 47 | ||
45 | expect(file.magnetUri).to.have.lengthOf.above(2) | 48 | expect(file.magnetUri).to.have.lengthOf.above(2) |
46 | expect(file.torrentUrl).to.equal(`http://${server.host}/lazy-static/torrents/${videoDetails.uuid}-${file.resolution.id}-hls.torrent`) | 49 | expect(file.torrentUrl).to.match( |
47 | expect(file.fileUrl).to.equal( | 50 | new RegExp(`http://${server.host}/lazy-static/torrents/${uuidRegex}-${file.resolution.id}-hls.torrent`) |
48 | `${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${videoDetails.uuid}-${file.resolution.id}-fragmented.mp4` | 51 | ) |
52 | expect(file.fileUrl).to.match( | ||
53 | new RegExp(`${baseUrl}/static/streaming-playlists/hls/${videoDetails.uuid}/${uuidRegex}-${file.resolution.id}-fragmented.mp4`) | ||
49 | ) | 54 | ) |
50 | expect(file.resolution.label).to.equal(resolution + 'p') | 55 | expect(file.resolution.label).to.equal(resolution + 'p') |
51 | 56 | ||
@@ -58,6 +63,7 @@ async function checkHlsPlaylist (servers: PeerTubeServer[], videoUUID: string, h | |||
58 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') | 63 | expect(torrent.files[0].path).to.exist.and.to.not.equal('') |
59 | } | 64 | } |
60 | 65 | ||
66 | // Check master playlist | ||
61 | { | 67 | { |
62 | await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) | 68 | await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) |
63 | 69 | ||
@@ -69,13 +75,16 @@ async function checkHlsPlaylist (servers: PeerTubeServer[], videoUUID: string, h | |||
69 | } | 75 | } |
70 | } | 76 | } |
71 | 77 | ||
78 | // Check resolution playlists | ||
72 | { | 79 | { |
73 | for (const resolution of resolutions) { | 80 | for (const resolution of resolutions) { |
74 | const subPlaylist = await server.streamingPlaylists.get({ | 81 | const subPlaylist = await server.streamingPlaylists.get({ |
75 | url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` | 82 | url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` |
76 | }) | 83 | }) |
77 | 84 | ||
78 | expect(subPlaylist).to.contain(`${videoUUID}-${resolution}-fragmented.mp4`) | 85 | const file = hlsFiles.find(f => f.resolution.id === resolution) |
86 | expect(subPlaylist).to.match(new RegExp(`${uuidRegex}-${resolution}-fragmented.mp4`)) | ||
87 | expect(subPlaylist).to.contain(basename(file.fileUrl)) | ||
79 | } | 88 | } |
80 | } | 89 | } |
81 | 90 | ||