aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-07 15:27:35 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-07 15:54:34 +0200
commitfdbda9e3d6564ec908733c7019305f6a3c363a9f (patch)
treec596034156f167e7cfafe41c4a3fc6adda488a0d /server/tests/utils/videos.ts
parent04de542abd940f9d2ca213fba3c68580c6c9b78a (diff)
downloadPeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.tar.gz
PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.tar.zst
PeerTube-fdbda9e3d6564ec908733c7019305f6a3c363a9f.zip
Add tests for npm run scripts
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}