diff options
Diffstat (limited to 'server/tests/utils/videos.ts')
-rw-r--r-- | server/tests/utils/videos.ts | 17 |
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 @@ | |||
1 | import { readFile } from 'fs' | ||
1 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
2 | import { join, isAbsolute } from 'path' | 3 | import { join, isAbsolute } from 'path' |
4 | import * as parseTorrent from 'parse-torrent' | ||
3 | 5 | ||
4 | import { makeGetRequest } from './requests' | 6 | import { makeGetRequest } from './requests' |
5 | import { readFilePromise } from './miscs' | 7 | import { readFilePromise } from './miscs' |
8 | import { ServerInfo } from './servers' | ||
6 | 9 | ||
7 | type VideoAttributes = { | 10 | type 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 | ||
238 | function 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 | ||
237 | export { | 251 | export { |
@@ -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 | } |