diff options
author | Chocobozzz <me@florianbigard.com> | 2023-05-04 15:29:34 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2023-05-09 08:57:34 +0200 |
commit | 5e47f6ab984a7d00782e4c7030afffa1ba480add (patch) | |
tree | 1ce586b591a8d71acbc301eba29b9a5e6490439e /server/tests/shared | |
parent | 6a4905602636afd6650c9e6f4d0fcc2105d91100 (diff) | |
download | PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.gz PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.tar.zst PeerTube-5e47f6ab984a7d00782e4c7030afffa1ba480add.zip |
Support studio transcoding in peertube runner
Diffstat (limited to 'server/tests/shared')
-rw-r--r-- | server/tests/shared/checks.ts | 17 | ||||
-rw-r--r-- | server/tests/shared/directories.ts | 21 |
2 files changed, 31 insertions, 7 deletions
diff --git a/server/tests/shared/checks.ts b/server/tests/shared/checks.ts index d7eb25bb5..feaef37c6 100644 --- a/server/tests/shared/checks.ts +++ b/server/tests/shared/checks.ts | |||
@@ -130,6 +130,22 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer | |||
130 | }) | 130 | }) |
131 | } | 131 | } |
132 | 132 | ||
133 | // --------------------------------------------------------------------------- | ||
134 | |||
135 | async function checkVideoDuration (server: PeerTubeServer, videoUUID: string, duration: number) { | ||
136 | const video = await server.videos.get({ id: videoUUID }) | ||
137 | |||
138 | expect(video.duration).to.be.approximately(duration, 1) | ||
139 | |||
140 | for (const file of video.files) { | ||
141 | const metadata = await server.videos.getFileMetadata({ url: file.metadataUrl }) | ||
142 | |||
143 | for (const stream of metadata.streams) { | ||
144 | expect(Math.round(stream.duration)).to.be.approximately(duration, 1) | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | |||
133 | export { | 149 | export { |
134 | dateIsValid, | 150 | dateIsValid, |
135 | testImageSize, | 151 | testImageSize, |
@@ -142,5 +158,6 @@ export { | |||
142 | checkBadStartPagination, | 158 | checkBadStartPagination, |
143 | checkBadCountPagination, | 159 | checkBadCountPagination, |
144 | checkBadSortPagination, | 160 | checkBadSortPagination, |
161 | checkVideoDuration, | ||
145 | expectLogContain | 162 | expectLogContain |
146 | } | 163 | } |
diff --git a/server/tests/shared/directories.ts b/server/tests/shared/directories.ts index a614cef7c..4f4282554 100644 --- a/server/tests/shared/directories.ts +++ b/server/tests/shared/directories.ts | |||
@@ -2,9 +2,11 @@ | |||
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { homedir } from 'os' | ||
6 | import { join } from 'path' | ||
5 | import { PeerTubeServer } from '@shared/server-commands' | 7 | import { PeerTubeServer } from '@shared/server-commands' |
6 | 8 | ||
7 | async function checkTmpIsEmpty (server: PeerTubeServer) { | 9 | export async function checkTmpIsEmpty (server: PeerTubeServer) { |
8 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) | 10 | await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ]) |
9 | 11 | ||
10 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { | 12 | if (await pathExists(server.getDirectoryPath('tmp/hls'))) { |
@@ -12,11 +14,11 @@ async function checkTmpIsEmpty (server: PeerTubeServer) { | |||
12 | } | 14 | } |
13 | } | 15 | } |
14 | 16 | ||
15 | async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { | 17 | export async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { |
16 | await checkDirectoryIsEmpty(server, 'tmp-persistent') | 18 | await checkDirectoryIsEmpty(server, 'tmp-persistent') |
17 | } | 19 | } |
18 | 20 | ||
19 | async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { | 21 | export async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { |
20 | const directoryPath = server.getDirectoryPath(directory) | 22 | const directoryPath = server.getDirectoryPath(directory) |
21 | 23 | ||
22 | const directoryExists = await pathExists(directoryPath) | 24 | const directoryExists = await pathExists(directoryPath) |
@@ -28,8 +30,13 @@ async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, | |||
28 | expect(filtered).to.have.lengthOf(0) | 30 | expect(filtered).to.have.lengthOf(0) |
29 | } | 31 | } |
30 | 32 | ||
31 | export { | 33 | export async function checkPeerTubeRunnerCacheIsEmpty () { |
32 | checkTmpIsEmpty, | 34 | const directoryPath = join(homedir(), '.cache', 'peertube-runner-nodejs', 'test', 'transcoding') |
33 | checkPersistentTmpIsEmpty, | 35 | |
34 | checkDirectoryIsEmpty | 36 | const directoryExists = await pathExists(directoryPath) |
37 | expect(directoryExists).to.be.true | ||
38 | |||
39 | const files = await readdir(directoryPath) | ||
40 | |||
41 | expect(files).to.have.lengthOf(0) | ||
35 | } | 42 | } |