X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server%2Ftests%2Fapi%2FmultiplePods.js;h=f1415f6f14ba2a3d90d96fed84c9187b5f8f72e0;hb=bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01;hp=ba4ce70c91d6c33eba5cc526e8951bff671ae8a5;hpb=6d8ada5f24b245d3c84d29d65013f5315cbeff27;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js index ba4ce70c9..f1415f6f1 100644 --- a/server/tests/api/multiplePods.js +++ b/server/tests/api/multiplePods.js @@ -11,7 +11,7 @@ webtorrent.silent = true describe('Test multiple pods', function () { let servers = [] - const to_remove = [] + const toRemove = [] before(function (done) { this.timeout(30000) @@ -19,19 +19,19 @@ describe('Test multiple pods', function () { async.series([ // Run servers function (next) { - utils.flushAndRunMultipleServers(3, function (servers_run) { - servers = servers_run + utils.flushAndRunMultipleServers(3, function (serversRun) { + servers = serversRun next() }) }, // Get the access tokens function (next) { - async.each(servers, function (server, callback_each) { - utils.loginAndGetAccessToken(server, function (err, access_token) { - if (err) return callback_each(err) + async.each(servers, function (server, callbackEach) { + utils.loginAndGetAccessToken(server, function (err, accessToken) { + if (err) return callbackEach(err) - server.access_token = access_token - callback_each() + server.accessToken = accessToken + callbackEach() }) }, next) }, @@ -82,7 +82,7 @@ describe('Test multiple pods', function () { if (err) throw err async.each(servers, function (server, callback) { - let base_magnet = null + let baseMagnet = null utils.getVideosList(server.url, function (err, res) { if (err) throw err @@ -95,6 +95,7 @@ describe('Test multiple pods', function () { expect(video.description).to.equal('my super description for pod 1') expect(video.podUrl).to.equal('http://localhost:9001') expect(video.magnetUri).to.exist + expect(video.duration).to.equal(10) if (server.url !== 'http://localhost:9001') { expect(video.isLocal).to.be.false @@ -103,13 +104,18 @@ describe('Test multiple pods', function () { } // All pods should have the same magnet Uri - if (base_magnet === null) { - base_magnet = video.magnetUri + if (baseMagnet === null) { + baseMagnet = video.magnetUri } else { expect(video.magnetUri).to.equal.magnetUri } - callback() + utils.testImage(server.url, 'video_short1.webm', video.thumbnailPath, function (err, test) { + if (err) throw err + expect(test).to.equal(true) + + callback() + }) }) }, done) } @@ -131,7 +137,7 @@ describe('Test multiple pods', function () { if (err) throw err async.each(servers, function (server, callback) { - let base_magnet = null + let baseMagnet = null utils.getVideosList(server.url, function (err, res) { if (err) throw err @@ -144,6 +150,7 @@ describe('Test multiple pods', function () { expect(video.description).to.equal('my super description for pod 2') expect(video.podUrl).to.equal('http://localhost:9002') expect(video.magnetUri).to.exist + expect(video.duration).to.equal(5) if (server.url !== 'http://localhost:9002') { expect(video.isLocal).to.be.false @@ -152,13 +159,18 @@ describe('Test multiple pods', function () { } // All pods should have the same magnet Uri - if (base_magnet === null) { - base_magnet = video.magnetUri + if (baseMagnet === null) { + baseMagnet = video.magnetUri } else { expect(video.magnetUri).to.equal.magnetUri } - callback() + utils.testImage(server.url, 'video_short2.webm', video.thumbnailPath, function (err, test) { + if (err) throw err + expect(test).to.equal(true) + + callback() + }) }) }, done) } @@ -181,7 +193,7 @@ describe('Test multiple pods', function () { function (err) { if (err) throw err - let base_magnet = null + let baseMagnet = null // All pods should have this video async.each(servers, function (server, callback) { utils.getVideosList(server.url, function (err, res) { @@ -190,17 +202,29 @@ describe('Test multiple pods', function () { const videos = res.body expect(videos).to.be.an('array') expect(videos.length).to.equal(4) - const video1 = videos[2] + + // We not sure about the order of the two last uploads + let video1 = null + let video2 = null + if (videos[2].name === 'my super name for pod 3') { + video1 = videos[2] + video2 = videos[3] + } else { + video1 = videos[3] + video2 = videos[2] + } + expect(video1.name).to.equal('my super name for pod 3') expect(video1.description).to.equal('my super description for pod 3') expect(video1.podUrl).to.equal('http://localhost:9003') expect(video1.magnetUri).to.exist + expect(video1.duration).to.equal(5) - const video2 = videos[3] expect(video2.name).to.equal('my super name for pod 3-2') expect(video2.description).to.equal('my super description for pod 3-2') expect(video2.podUrl).to.equal('http://localhost:9003') expect(video2.magnetUri).to.exist + expect(video2.duration).to.equal(5) if (server.url !== 'http://localhost:9003') { expect(video1.isLocal).to.be.false @@ -211,13 +235,23 @@ describe('Test multiple pods', function () { } // All pods should have the same magnet Uri - if (base_magnet === null) { - base_magnet = video2.magnetUri + if (baseMagnet === null) { + baseMagnet = video2.magnetUri } else { expect(video2.magnetUri).to.equal.magnetUri } - callback() + utils.testImage(server.url, 'video_short3.webm', video1.thumbnailPath, function (err, test) { + if (err) throw err + expect(test).to.equal(true) + + utils.testImage(server.url, 'video_short.webm', video2.thumbnailPath, function (err, test) { + if (err) throw err + expect(test).to.equal(true) + + callback() + }) + }) }) }, done) } @@ -234,8 +268,8 @@ describe('Test multiple pods', function () { if (err) throw err const video = res.body[0] - to_remove.push(res.body[2].id) - to_remove.push(res.body[3].id) + toRemove.push(res.body[2].id) + toRemove.push(res.body[3].id) webtorrent.add(video.magnetUri, function (torrent) { expect(torrent.files).to.exist @@ -309,10 +343,10 @@ describe('Test multiple pods', function () { async.series([ function (next) { - utils.removeVideo(servers[2].url, servers[2].access_token, to_remove[0], next) + utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[0], next) }, function (next) { - utils.removeVideo(servers[2].url, servers[2].access_token, to_remove[1], next) + utils.removeVideo(servers[2].url, servers[2].accessToken, toRemove[1], next) }], function (err) { if (err) throw err @@ -330,10 +364,10 @@ describe('Test multiple pods', function () { expect(videos).to.be.an('array') expect(videos.length).to.equal(2) expect(videos[0].id).not.to.equal(videos[1].id) - expect(videos[0].id).not.to.equal(to_remove[0]) - expect(videos[1].id).not.to.equal(to_remove[0]) - expect(videos[0].id).not.to.equal(to_remove[1]) - expect(videos[1].id).not.to.equal(to_remove[1]) + expect(videos[0].id).not.to.equal(toRemove[0]) + expect(videos[1].id).not.to.equal(toRemove[0]) + expect(videos[0].id).not.to.equal(toRemove[1]) + expect(videos[1].id).not.to.equal(toRemove[1]) callback() })