aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-03 22:41:46 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-03 22:41:46 +0200
commit3a8a8b51228070d8e6a01ea6e460534aa0a20efc (patch)
tree00dadc882a50079ea29b28078ed45a8efc4fec3d /server/tests
parent6d8ada5f24b245d3c84d29d65013f5315cbeff27 (diff)
downloadPeerTube-3a8a8b51228070d8e6a01ea6e460534aa0a20efc.tar.gz
PeerTube-3a8a8b51228070d8e6a01ea6e460534aa0a20efc.tar.zst
PeerTube-3a8a8b51228070d8e6a01ea6e460534aa0a20efc.zip
Video duration support (server)
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/multiplePods.js5
-rw-r--r--server/tests/api/singlePod.js32
2 files changed, 37 insertions, 0 deletions
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index ba4ce70c9..adc99f714 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -95,6 +95,7 @@ describe('Test multiple pods', function () {
95 expect(video.description).to.equal('my super description for pod 1') 95 expect(video.description).to.equal('my super description for pod 1')
96 expect(video.podUrl).to.equal('http://localhost:9001') 96 expect(video.podUrl).to.equal('http://localhost:9001')
97 expect(video.magnetUri).to.exist 97 expect(video.magnetUri).to.exist
98 expect(video.duration).to.equal(10)
98 99
99 if (server.url !== 'http://localhost:9001') { 100 if (server.url !== 'http://localhost:9001') {
100 expect(video.isLocal).to.be.false 101 expect(video.isLocal).to.be.false
@@ -144,6 +145,7 @@ describe('Test multiple pods', function () {
144 expect(video.description).to.equal('my super description for pod 2') 145 expect(video.description).to.equal('my super description for pod 2')
145 expect(video.podUrl).to.equal('http://localhost:9002') 146 expect(video.podUrl).to.equal('http://localhost:9002')
146 expect(video.magnetUri).to.exist 147 expect(video.magnetUri).to.exist
148 expect(video.duration).to.equal(5)
147 149
148 if (server.url !== 'http://localhost:9002') { 150 if (server.url !== 'http://localhost:9002') {
149 expect(video.isLocal).to.be.false 151 expect(video.isLocal).to.be.false
@@ -190,17 +192,20 @@ describe('Test multiple pods', function () {
190 const videos = res.body 192 const videos = res.body
191 expect(videos).to.be.an('array') 193 expect(videos).to.be.an('array')
192 expect(videos.length).to.equal(4) 194 expect(videos.length).to.equal(4)
195
193 const video1 = videos[2] 196 const video1 = videos[2]
194 expect(video1.name).to.equal('my super name for pod 3') 197 expect(video1.name).to.equal('my super name for pod 3')
195 expect(video1.description).to.equal('my super description for pod 3') 198 expect(video1.description).to.equal('my super description for pod 3')
196 expect(video1.podUrl).to.equal('http://localhost:9003') 199 expect(video1.podUrl).to.equal('http://localhost:9003')
197 expect(video1.magnetUri).to.exist 200 expect(video1.magnetUri).to.exist
201 expect(video1.duration).to.equal(5)
198 202
199 const video2 = videos[3] 203 const video2 = videos[3]
200 expect(video2.name).to.equal('my super name for pod 3-2') 204 expect(video2.name).to.equal('my super name for pod 3-2')
201 expect(video2.description).to.equal('my super description for pod 3-2') 205 expect(video2.description).to.equal('my super description for pod 3-2')
202 expect(video2.podUrl).to.equal('http://localhost:9003') 206 expect(video2.podUrl).to.equal('http://localhost:9003')
203 expect(video2.magnetUri).to.exist 207 expect(video2.magnetUri).to.exist
208 expect(video2.duration).to.equal(5)
204 209
205 if (server.url !== 'http://localhost:9003') { 210 if (server.url !== 'http://localhost:9003') {
206 expect(video1.isLocal).to.be.false 211 expect(video1.isLocal).to.be.false
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index efd8a64bc..e2999530e 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -4,6 +4,7 @@ const async = require('async')
4const chai = require('chai') 4const chai = require('chai')
5const expect = chai.expect 5const expect = chai.expect
6const fs = require('fs') 6const fs = require('fs')
7const keyBy = require('lodash/keyBy')
7const pathUtils = require('path') 8const pathUtils = require('path')
8 9
9const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent')) 10const webtorrent = require(pathUtils.join(__dirname, '../../lib/webtorrent'))
@@ -165,6 +166,37 @@ describe('Test a single pod', function () {
165 }) 166 })
166 }) 167 })
167 168
169 it('Should upload 6 videos', function (done) {
170 this.timeout(25000)
171 const videos = [
172 'video_short.mp4', 'video_short.ogv', 'video_short.webm',
173 'video_short1.webm', 'video_short2.webm', 'video_short3.webm'
174 ]
175 async.each(videos, function (video, callback_each) {
176 utils.uploadVideo(server.url, server.access_token, video + ' name', video + ' description', video, callback_each)
177 }, done)
178 })
179
180 it('Should have the correct durations', function (done) {
181 utils.getVideosList(server.url, function (err, res) {
182 if (err) throw err
183
184 const videos = res.body
185 expect(videos).to.be.an('array')
186 expect(videos.length).to.equal(6)
187
188 const videos_by_name = keyBy(videos, 'name')
189 expect(videos_by_name['video_short.mp4 name'].duration).to.equal(5)
190 expect(videos_by_name['video_short.ogv name'].duration).to.equal(5)
191 expect(videos_by_name['video_short.webm name'].duration).to.equal(5)
192 expect(videos_by_name['video_short1.webm name'].duration).to.equal(10)
193 expect(videos_by_name['video_short2.webm name'].duration).to.equal(5)
194 expect(videos_by_name['video_short3.webm name'].duration).to.equal(5)
195
196 done()
197 })
198 })
199
168 after(function (done) { 200 after(function (done) {
169 process.kill(-server.app.pid) 201 process.kill(-server.app.pid)
170 process.kill(-webtorrent.app.pid) 202 process.kill(-webtorrent.app.pid)