From 0a6658fdcbd779ada8f3758048c326e997902d5a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 11 Jul 2017 16:01:56 +0200 Subject: Use global uuid instead of remoteId for videos --- server/tests/api/check-params/remotes.js | 2 +- server/tests/api/multiple-pods.js | 31 +++++++++++++++++++++++++++++++ server/tests/api/single-pod.js | 21 +++++++++++++++++++-- 3 files changed, 51 insertions(+), 3 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/check-params/remotes.js b/server/tests/api/check-params/remotes.js index 96361c643..7cb99c4ae 100644 --- a/server/tests/api/check-params/remotes.js +++ b/server/tests/api/check-params/remotes.js @@ -44,7 +44,7 @@ describe('Test remote videos API validators', function () { describe('When adding a video', function () { it('Should check when adding a video') - it('Should not add an existing remoteId and host pair') + it('Should not add an existing uuid') }) describe('When removing a video', function () { diff --git a/server/tests/api/multiple-pods.js b/server/tests/api/multiple-pods.js index c3ee77f0c..1bc6157e8 100644 --- a/server/tests/api/multiple-pods.js +++ b/server/tests/api/multiple-pods.js @@ -20,6 +20,7 @@ const videosUtils = require('../utils/videos') describe('Test multiple pods', function () { let servers = [] const toRemove = [] + let videoUUID = '' before(function (done) { this.timeout(120000) @@ -746,6 +747,36 @@ describe('Test multiple pods', function () { expect(videos[0].name).not.to.equal(toRemove[1].name) expect(videos[1].name).not.to.equal(toRemove[1].name) + videoUUID = videos[0].uuid + + callback() + }) + }, done) + }) + + it('Should get the same video by UUID on each pod', function (done) { + let baseVideo = null + each(servers, function (server, callback) { + videosUtils.getVideo(server.url, videoUUID, function (err, res) { + if (err) throw err + + const video = res.body + + if (baseVideo === null) { + baseVideo = video + return callback() + } + + expect(baseVideo.name).to.equal(video.name) + expect(baseVideo.uuid).to.equal(video.uuid) + expect(baseVideo.category).to.equal(video.category) + expect(baseVideo.language).to.equal(video.language) + expect(baseVideo.licence).to.equal(video.licence) + expect(baseVideo.category).to.equal(video.category) + expect(baseVideo.nsfw).to.equal(video.nsfw) + expect(baseVideo.author).to.equal(video.author) + expect(baseVideo.tags).to.deep.equal(video.tags) + callback() }) }, done) diff --git a/server/tests/api/single-pod.js b/server/tests/api/single-pod.js index e08da0517..0dac9a183 100644 --- a/server/tests/api/single-pod.js +++ b/server/tests/api/single-pod.js @@ -19,6 +19,7 @@ const videosUtils = require('../utils/videos') describe('Test a single pod', function () { let server = null let videoId = -1 + let videoUUID = '' let videosListBase = null before(function (done) { @@ -140,6 +141,7 @@ describe('Test a single pod', function () { expect(test).to.equal(true) videoId = video.id + videoUUID = video.uuid webtorrent.add(video.magnetUri, function (torrent) { expect(torrent.files).to.exist @@ -181,18 +183,33 @@ describe('Test a single pod', function () { if (err) throw err expect(test).to.equal(true) - // Wait the async views increment + // Wait the async views increment setTimeout(done, 500) }) }) }) + it('Should get the video by UUID', function (done) { + // Yes, this could be long + this.timeout(60000) + + videosUtils.getVideo(server.url, videoUUID, function (err, res) { + if (err) throw err + + const video = res.body + expect(video.name).to.equal('my super name') + + // Wait the async views increment + setTimeout(done, 500) + }) + }) + it('Should have the views updated', function (done) { videosUtils.getVideo(server.url, videoId, function (err, res) { if (err) throw err const video = res.body - expect(video.views).to.equal(1) + expect(video.views).to.equal(2) done() }) -- cgit v1.2.3