From fdbda9e3d6564ec908733c7019305f6a3c363a9f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Sep 2017 15:27:35 +0200 Subject: Add tests for npm run scripts --- server/tests/utils/videos.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'server/tests/utils/videos.ts') 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 @@ +import { readFile } from 'fs' import * as request from 'supertest' import { join, isAbsolute } from 'path' +import * as parseTorrent from 'parse-torrent' import { makeGetRequest } from './requests' import { readFilePromise } from './miscs' +import { ServerInfo } from './servers' type VideoAttributes = { name?: string @@ -232,6 +235,17 @@ function rateVideo (url: string, accessToken: string, id: number, rating: string .expect(specialStatus) } +function parseTorrentVideo (server: ServerInfo, videoUUID: string) { + return new Promise((res, rej) => { + const torrentPath = join(__dirname, '..', '..', '..', 'test' + server.serverNumber, 'torrents', videoUUID + '.torrent') + readFile(torrentPath, (err, data) => { + if (err) return rej(err) + + return res(parseTorrent(data)) + }) + }) +} + // --------------------------------------------------------------------------- export { @@ -250,5 +264,6 @@ export { testVideoImage, uploadVideo, updateVideo, - rateVideo + rateVideo, + parseTorrentVideo } -- cgit v1.2.3