aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/shared
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/shared')
-rw-r--r--server/tests/shared/checks.ts17
-rw-r--r--server/tests/shared/directories.ts21
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
135async 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
133export { 149export {
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
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { pathExists, readdir } from 'fs-extra' 4import { pathExists, readdir } from 'fs-extra'
5import { homedir } from 'os'
6import { join } from 'path'
5import { PeerTubeServer } from '@shared/server-commands' 7import { PeerTubeServer } from '@shared/server-commands'
6 8
7async function checkTmpIsEmpty (server: PeerTubeServer) { 9export 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
15async function checkPersistentTmpIsEmpty (server: PeerTubeServer) { 17export async function checkPersistentTmpIsEmpty (server: PeerTubeServer) {
16 await checkDirectoryIsEmpty(server, 'tmp-persistent') 18 await checkDirectoryIsEmpty(server, 'tmp-persistent')
17} 19}
18 20
19async function checkDirectoryIsEmpty (server: PeerTubeServer, directory: string, exceptions: string[] = []) { 21export 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
31export { 33export 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}