aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos/video-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-28 13:59:22 +0100
committerChocobozzz <me@florianbigard.com>2017-12-28 13:59:22 +0100
commitc5d31dba56d669c0df0209761c43c5a6ac7cec4a (patch)
treefe72b56a1c0e7beb6e092c393a00ddfe93a5d71f /server/tests/api/videos/video-transcoder.ts
parentdb799da3d2b2ea465165df78ff71effa653b6309 (diff)
downloadPeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.gz
PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.tar.zst
PeerTube-c5d31dba56d669c0df0209761c43c5a6ac7cec4a.zip
Tests directories refractor
Diffstat (limited to 'server/tests/api/videos/video-transcoder.ts')
-rw-r--r--server/tests/api/videos/video-transcoder.ts97
1 files changed, 97 insertions, 0 deletions
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
new file mode 100644
index 000000000..27927a594
--- /dev/null
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -0,0 +1,97 @@
1/* tslint:disable:no-unused-expression */
2
3import 'mocha'
4import * as chai from 'chai'
5const expect = chai.expect
6
7import {
8 ServerInfo,
9 flushTests,
10 uploadVideo,
11 getVideosList,
12 wait,
13 setAccessTokensToServers,
14 flushAndRunMultipleServers,
15 killallServers,
16 webtorrentAdd,
17 getVideo
18} from '../../utils/index'
19
20describe('Test video transcoding', function () {
21 let servers: ServerInfo[] = []
22
23 before(async function () {
24 this.timeout(10000)
25
26 // Run servers
27 servers = await flushAndRunMultipleServers(2)
28
29 await setAccessTokensToServers(servers)
30 })
31
32 it('Should not transcode video on server 1', async function () {
33 this.timeout(60000)
34
35 const videoAttributes = {
36 name: 'my super name for server 1',
37 description: 'my super description for server 1',
38 fixture: 'video_short.webm'
39 }
40 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
41
42 await wait(10000)
43
44 const res = await getVideosList(servers[0].url)
45 const video = res.body.data[0]
46
47 const res2 = await getVideo(servers[0].url, video.id)
48 const videoDetails = res2.body
49 expect(videoDetails.files).to.have.lengthOf(1)
50
51 const magnetUri = videoDetails.files[0].magnetUri
52 expect(magnetUri).to.match(/\.webm/)
53
54 const torrent = await webtorrentAdd(magnetUri)
55 expect(torrent.files).to.be.an('array')
56 expect(torrent.files.length).to.equal(1)
57 expect(torrent.files[0].path).match(/\.webm$/)
58 })
59
60 it('Should transcode video on server 2', async function () {
61 this.timeout(60000)
62
63 const videoAttributes = {
64 name: 'my super name for server 2',
65 description: 'my super description for server 2',
66 fixture: 'video_short.webm'
67 }
68 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
69
70 await wait(20000)
71
72 const res = await getVideosList(servers[1].url)
73
74 const video = res.body.data[0]
75 const res2 = await getVideo(servers[1].url, video.id)
76 const videoDetails = res2.body
77
78 expect(videoDetails.files).to.have.lengthOf(4)
79
80 const magnetUri = videoDetails.files[0].magnetUri
81 expect(magnetUri).to.match(/\.mp4/)
82
83 const torrent = await webtorrentAdd(magnetUri)
84 expect(torrent.files).to.be.an('array')
85 expect(torrent.files.length).to.equal(1)
86 expect(torrent.files[0].path).match(/\.mp4$/)
87 })
88
89 after(async function () {
90 killallServers(servers)
91
92 // Keep the logs if the test failed
93 if (this['ok']) {
94 await flushTests()
95 }
96 })
97})