aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/video-transcoder.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-09-04 21:21:47 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-09-04 21:30:18 +0200
commit0e1dc3e7c69995c691e1dd82e3c2bc68748661ca (patch)
treef2a4b5cffc72e33c902b67083bbaa35b6f22f0ca /server/tests/api/video-transcoder.ts
parentb0f9f39ed70299a208d1b388c72de8b7f3510cb7 (diff)
downloadPeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.gz
PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.tar.zst
PeerTube-0e1dc3e7c69995c691e1dd82e3c2bc68748661ca.zip
Convert tests to typescript
Diffstat (limited to 'server/tests/api/video-transcoder.ts')
-rw-r--r--server/tests/api/video-transcoder.ts86
1 files changed, 86 insertions, 0 deletions
diff --git a/server/tests/api/video-transcoder.ts b/server/tests/api/video-transcoder.ts
new file mode 100644
index 000000000..228cef007
--- /dev/null
+++ b/server/tests/api/video-transcoder.ts
@@ -0,0 +1,86 @@
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} from '../utils'
18
19describe('Test video transcoding', function () {
20 let servers: ServerInfo[] = []
21
22 before(async function () {
23 this.timeout(30000)
24
25 // Run servers
26 servers = await flushAndRunMultipleServers(2)
27
28 await setAccessTokensToServers(servers)
29 })
30
31 it('Should not transcode video on server 1', async function () {
32 this.timeout(60000)
33
34 const videoAttributes = {
35 name: 'my super name for pod 1',
36 description: 'my super description for pod 1',
37 fixture: 'video_short.webm'
38 }
39 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
40
41 await wait(30000)
42
43 const res = await getVideosList(servers[0].url)
44 const video = res.body.data[0]
45 const magnetUri = video.files[0].magnetUri
46 expect(magnetUri).to.match(/\.webm/)
47
48 const torrent = await webtorrentAdd(magnetUri)
49 expect(torrent.files).to.be.an('array')
50 expect(torrent.files.length).to.equal(1)
51 expect(torrent.files[0].path).match(/\.webm$/)
52 })
53
54 it('Should transcode video on server 2', async function () {
55 this.timeout(60000)
56
57 const videoAttributes = {
58 name: 'my super name for pod 2',
59 description: 'my super description for pod 2',
60 fixture: 'video_short.webm'
61 }
62 await uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes)
63
64 await wait(30000)
65
66 const res = await getVideosList(servers[1].url)
67
68 const video = res.body.data[0]
69 const magnetUri = video.files[0].magnetUri
70 expect(magnetUri).to.match(/\.mp4/)
71
72 const torrent = await webtorrentAdd(magnetUri)
73 expect(torrent.files).to.be.an('array')
74 expect(torrent.files.length).to.equal(1)
75 expect(torrent.files[0].path).match(/\.mp4$/)
76 })
77
78 after(async function () {
79 killallServers(servers)
80
81 // Keep the logs if the test failed
82 if (this['ok']) {
83 await flushTests()
84 }
85 })
86})