aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/multiple-pods.js29
-rw-r--r--server/tests/api/single-pod.js19
2 files changed, 40 insertions, 8 deletions
diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js
index 4442a7ff7..169a9f2e0 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')
@@ -311,7 +312,7 @@ describe('Test multiple pods', function () {
311 expect(torrent.files.length).to.equal(1) 312 expect(torrent.files.length).to.equal(1)
312 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 313 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
313 314
314 done() 315 webtorrent.remove(video.magnetUri, done)
315 }) 316 })
316 }) 317 })
317 }) 318 })
@@ -330,7 +331,7 @@ describe('Test multiple pods', function () {
330 expect(torrent.files.length).to.equal(1) 331 expect(torrent.files.length).to.equal(1)
331 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 332 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
332 333
333 done() 334 webtorrent.remove(video.magnetUri, done)
334 }) 335 })
335 }) 336 })
336 }) 337 })
@@ -349,7 +350,7 @@ describe('Test multiple pods', function () {
349 expect(torrent.files.length).to.equal(1) 350 expect(torrent.files.length).to.equal(1)
350 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 351 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
351 352
352 done() 353 webtorrent.remove(video.magnetUri, done)
353 }) 354 })
354 }) 355 })
355 }) 356 })
@@ -368,7 +369,7 @@ describe('Test multiple pods', function () {
368 expect(torrent.files.length).to.equal(1) 369 expect(torrent.files.length).to.equal(1)
369 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 370 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
370 371
371 done() 372 webtorrent.remove(video.magnetUri, done)
372 }) 373 })
373 }) 374 })
374 }) 375 })
@@ -390,7 +391,12 @@ describe('Test multiple pods', function () {
390 }) 391 })
391 392
392 it('Should have the video 3 updated on each pod', function (done) { 393 it('Should have the video 3 updated on each pod', function (done) {
394 this.timeout(200000)
395
393 each(servers, function (server, callback) { 396 each(servers, function (server, callback) {
397 // Avoid "duplicate torrent" errors
398 const webtorrent = new WebTorrent()
399
394 videosUtils.getVideosList(server.url, function (err, res) { 400 videosUtils.getVideosList(server.url, function (err, res) {
395 if (err) throw err 401 if (err) throw err
396 402
@@ -404,7 +410,18 @@ describe('Test multiple pods', function () {
404 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) 410 expect(videoUpdated.tags).to.deep.equal([ 'tagup1', 'tagup2' ])
405 expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true 411 expect(miscsUtils.dateIsValid(videoUpdated.updatedAt, 20000)).to.be.true
406 412
407 callback() 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 webtorrent.remove(videoUpdated.magnetUri, callback)
423 })
424 })
408 }) 425 })
409 }, done) 426 }, done)
410 }) 427 })
diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js
index 29512dfc6..04b93fac7 100644
--- a/server/tests/api/single-pod.js
+++ b/server/tests/api/single-pod.js
@@ -96,7 +96,7 @@ describe('Test a single pod', function () {
96 expect(torrent.files.length).to.equal(1) 96 expect(torrent.files.length).to.equal(1)
97 expect(torrent.files[0].path).to.exist.and.to.not.equal('') 97 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
98 98
99 done() 99 webtorrent.remove(video.magnetUri, done)
100 }) 100 })
101 }) 101 })
102 }) 102 })
@@ -515,6 +515,8 @@ describe('Test a single pod', function () {
515 }) 515 })
516 516
517 it('Should have the video updated', function (done) { 517 it('Should have the video updated', function (done) {
518 this.timeout(60000)
519
518 videosUtils.getVideo(server.url, videoId, function (err, res) { 520 videosUtils.getVideo(server.url, videoId, function (err, res) {
519 if (err) throw err 521 if (err) throw err
520 522
@@ -529,7 +531,20 @@ describe('Test a single pod', function () {
529 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true 531 expect(miscsUtils.dateIsValid(video.createdAt)).to.be.true
530 expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true 532 expect(miscsUtils.dateIsValid(video.updatedAt)).to.be.true
531 533
532 done() 534 videosUtils.testVideoImage(server.url, 'video_short3.webm', video.thumbnailPath, function (err, test) {
535 if (err) throw err
536 expect(test).to.equal(true)
537
538 videoId = video.id
539
540 webtorrent.add(video.magnetUri, function (torrent) {
541 expect(torrent.files).to.exist
542 expect(torrent.files.length).to.equal(1)
543 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
544
545 done()
546 })
547 })
533 }) 548 })
534 }) 549 })
535 550