aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/utils/videos.ts')
-rw-r--r--server/tests/utils/videos.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos.ts
index 42b7dd05a..509a2430a 100644
--- a/server/tests/utils/videos.ts
+++ b/server/tests/utils/videos.ts
@@ -1,8 +1,11 @@
1import { readFile } from 'fs'
1import * as request from 'supertest' 2import * as request from 'supertest'
2import { join, isAbsolute } from 'path' 3import { join, isAbsolute } from 'path'
4import * as parseTorrent from 'parse-torrent'
3 5
4import { makeGetRequest } from './requests' 6import { makeGetRequest } from './requests'
5import { readFilePromise } from './miscs' 7import { readFilePromise } from './miscs'
8import { ServerInfo } from './servers'
6 9
7type VideoAttributes = { 10type VideoAttributes = {
8 name?: string 11 name?: string
@@ -232,6 +235,17 @@ function rateVideo (url: string, accessToken: string, id: number, rating: string
232 .expect(specialStatus) 235 .expect(specialStatus)
233} 236}
234 237
238function parseTorrentVideo (server: ServerInfo, videoUUID: string) {
239 return new Promise<any>((res, rej) => {
240 const torrentPath = join(__dirname, '..', '..', '..', 'test' + server.serverNumber, 'torrents', videoUUID + '.torrent')
241 readFile(torrentPath, (err, data) => {
242 if (err) return rej(err)
243
244 return res(parseTorrent(data))
245 })
246 })
247}
248
235// --------------------------------------------------------------------------- 249// ---------------------------------------------------------------------------
236 250
237export { 251export {
@@ -250,5 +264,6 @@ export {
250 testVideoImage, 264 testVideoImage,
251 uploadVideo, 265 uploadVideo,
252 updateVideo, 266 updateVideo,
253 rateVideo 267 rateVideo,
268 parseTorrentVideo
254} 269}