diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-07 15:27:35 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-07 15:54:34 +0200 |
commit | fdbda9e3d6564ec908733c7019305f6a3c363a9f (patch) | |
tree | c596034156f167e7cfafe41c4a3fc6adda488a0d /server/tests/utils/videos.ts | |
parent | 04de542abd940f9d2ca213fba3c68580c6c9b78a (diff) | |
download | PeerTube-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.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 | } |