aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/multiple-pods.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/multiple-pods.js')
-rw-r--r--server/tests/api/multiple-pods.js87
1 files changed, 72 insertions, 15 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index be278d7c5..df12ba0e9 100644
--- a/server/tests/api/multiple-pods.js
+++ b/server/tests/api/multiple-pods.js
@@ -4,7 +4,8 @@ const chai = require('chai')
4const each = require('async/each') 4const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const series = require('async/series') 6const series = require('async/series')
7const webtorrent = new (require('webtorrent'))() 7const WebTorrent = require('webtorrent')
8const webtorrent = new WebTorrent()
8 9
9const loginUtils = require('../utils/login') 10const loginUtils = require('../utils/login')
10const miscsUtils = require('../utils/miscs') 11const miscsUtils = require('../utils/miscs')
@@ -104,7 +105,8 @@ describe('Test multiple pods', function () {
104 expect(video.magnetUri).to.exist 105 expect(video.magnetUri).to.exist
105 expect(video.duration).to.equal(10) 106 expect(video.duration).to.equal(10)
106 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) 107 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
107 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 108 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
109 expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
108 expect(video.author).to.equal('root') 110 expect(video.author).to.equal('root')
109 111
110 if (server.url !== 'http://localhost:9001') { 112 if (server.url !== 'http://localhost:9001') {
@@ -166,7 +168,8 @@ describe('Test multiple pods', function () {
166 expect(video.magnetUri).to.exist 168 expect(video.magnetUri).to.exist
167 expect(video.duration).to.equal(5) 169 expect(video.duration).to.equal(5)
168 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) 170 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
169 expect(miscsUtils.dateIsValid(video.createdDate)).to.be.true 171 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
172 expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
170 expect(video.author).to.equal('root') 173 expect(video.author).to.equal('root')
171 174
172 if (server.url !== 'http://localhost:9002') { 175 if (server.url !== 'http://localhost:9002') {
@@ -246,7 +249,8 @@ describe('Test multiple pods', function () {
246 expect(video1.duration).to.equal(5) 249 expect(video1.duration).to.equal(5)
247 expect(video1.tags).to.deep.equal([ 'tag1p3' ]) 250 expect(video1.tags).to.deep.equal([ 'tag1p3' ])
248 expect(video1.author).to.equal('root') 251 expect(video1.author).to.equal('root')
249 expect(miscsUtils.dateIsValid(video1.createdDate)).to.be.true 252 expect(miscsUtils.dateIsValid(video1.createdAt)).to.be.true
253 expect(miscsUtils.dateIsValid(video1.updatedAt)).to.be.true
250 254
251 expect(video2.name).to.equal('my super name for pod 3-2') 255 expect(video2.name).to.equal('my super name for pod 3-2')
252 expect(video2.description).to.equal('my super description for pod 3-2') 256 expect(video2.description).to.equal('my super description for pod 3-2')
@@ -255,7 +259,8 @@ describe('Test multiple pods', function () {
255 expect(video2.duration).to.equal(5) 259 expect(video2.duration).to.equal(5)
256 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) 260 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
257 expect(video2.author).to.equal('root') 261 expect(video2.author).to.equal('root')
258 expect(miscsUtils.dateIsValid(video2.createdDate)).to.be.true 262 expect(miscsUtils.dateIsValid(video2.createdAt)).to.be.true
263 expect(miscsUtils.dateIsValid(video2.updatedAt)).to.be.true
259 264
260 if (server.url !== 'http://localhost:9003') { 265 if (server.url !== 'http://localhost:9003') {
261 expect(video1.isLocal).to.be.false 266 expect(video1.isLocal).to.be.false
@@ -299,8 +304,8 @@ describe('Test multiple pods', function () {
299 if (err) throw err 304 if (err) throw err
300 305
301 const video = res.body.data[0] 306 const video = res.body.data[0]
302 toRemove.push(res.body.data[2].id) 307 toRemove.push(res.body.data[2])
303 toRemove.push(res.body.data[3].id) 308 toRemove.push(res.body.data[3])
304 309
305 webtorrent.add(video.magnetUri, function (torrent) { 310 webtorrent.add(video.magnetUri, function (torrent) {
306 expect(torrent.files).to.exist 311 expect(torrent.files).to.exist
@@ -368,16 +373,68 @@ describe('Test multiple pods', function () {
368 }) 373 })
369 }) 374 })
370 }) 375 })
376 })
377
378 describe('Should manipulate these videos', function () {
379 it('Should update the video 3 by asking pod 3', function (done) {
380 this.timeout(15000)
381
382 const name = 'my super video updated'
383 const description = 'my super description updated'
384 const tags = [ 'tagup1', 'tagup2' ]
385
386 videosUtils.updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, name, description, tags, function (err) {
387 if (err) throw err
388
389 setTimeout(done, 11000)
390 })
391 })
392
393 it('Should have the video 3 updated on each pod', function (done) {
394 this.timeout(200000)
395
396 each(servers, function (server, callback) {
397 // Avoid "duplicate torrent" errors
398 const webtorrent = new WebTorrent()
399
400 videosUtils.getVideosList(server.url, function (err, res) {
401 if (err) throw err
402
403 const videos = res.body.data
404 const videoUpdated = videos.find(function (video) {
405 return video.name === 'my super video updated'
406 })
407
408 expect(!!videoUpdated).to.be.true
409 expect(videoUpdated.description).to.equal('my super description updated')
410 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
411 expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
412
413 videosUtils.testVideoImage(server.url, 'video_short3.webm', videoUpdated.thumbnailPath, function (err, test) {
414 if (err) throw err
415 expect(test).to.equal(true)
416
417 webtorrent.add(videoUpdated.magnetUri, function (torrent) {
418 expect(torrent.files).to.exist
419 expect(torrent.files.length).to.equal(1)
420 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
421
422 callback()
423 })
424 })
425 })
426 }, done)
427 })
371 428
372 it('Should remove the file 3 and 3-2 by asking pod 3', function (done) { 429 it('Should remove the videos 3 and 3-2 by asking pod 3', function (done) {
373 this.timeout(15000) 430 this.timeout(15000)
374 431
375 series([ 432 series([
376 function (next) { 433 function (next) {
377 videosUtils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next) 434 videosUtils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, next)
378 }, 435 },
379 function (next) { 436 function (next) {
380 videosUtils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[1], next) 437 videosUtils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id, next)
381 }], 438 }],
382 function (err) { 439 function (err) {
383 if (err) throw err 440 if (err) throw err
@@ -394,11 +451,11 @@ describe('Test multiple pods', function () {
394 const videos = res.body.data 451 const videos = res.body.data
395 expect(videos).to.be.an('array') 452 expect(videos).to.be.an('array')
396 expect(videos.length).to.equal(2) 453 expect(videos.length).to.equal(2)
397 expect(videos[0].id).not.to.equal(videos[1].id) 454 expect(videos[0].name).not.to.equal(videos[1].name)
398 expect(videos[0].id).not.to.equal(toRemove[0]) 455 expect(videos[0].name).not.to.equal(toRemove[0].name)
399 expect(videos[1].id).not.to.equal(toRemove[0]) 456 expect(videos[1].name).not.to.equal(toRemove[0].name)
400 expect(videos[0].id).not.to.equal(toRemove[1]) 457 expect(videos[0].name).not.to.equal(toRemove[1].name)
401 expect(videos[1].id).not.to.equal(toRemove[1]) 458 expect(videos[1].name).not.to.equal(toRemove[1].name)
402 459
403 callback() 460 callback()
404 }) 461 })