From 528a9efa8272532bbd0dafc35c3e05e57c50f61e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 18 Jun 2016 16:13:54 +0200 Subject: Try to make a better communication (between pods) module --- server/tests/api/checkParams.js | 24 ++++++++---------------- server/tests/api/friendsAdvanced.js | 19 +++++++++++++++++-- server/tests/api/friendsBasic.js | 3 ++- server/tests/api/multiplePods.js | 4 ++++ 4 files changed, 31 insertions(+), 19 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js index 95a7738f8..7f22a37cc 100644 --- a/server/tests/api/checkParams.js +++ b/server/tests/api/checkParams.js @@ -90,33 +90,27 @@ describe('Test parameters validator', function () { it('Should fail without public key', function (done) { const data = { - data: { - url: 'http://coucou.com' - } + url: 'http://coucou.com' } makePostBodyRequest(path, data, done) }) it('Should fail without an url', function (done) { const data = { - data: { - publicKey: 'mysuperpublickey' - } + publicKey: 'mysuperpublickey' } makePostBodyRequest(path, data, done) }) it('Should fail with an incorrect url', function (done) { const data = { - data: { - url: 'coucou.com', - publicKey: 'mysuperpublickey' - } + url: 'coucou.com', + publicKey: 'mysuperpublickey' } makePostBodyRequest(path, data, function () { - data.data.url = 'http://coucou' + data.url = 'http://coucou' makePostBodyRequest(path, data, function () { - data.data.url = 'coucou' + data.url = 'coucou' makePostBodyRequest(path, data, done) }) }) @@ -124,10 +118,8 @@ describe('Test parameters validator', function () { it('Should succeed with the correct parameters', function (done) { const data = { - data: { - url: 'http://coucou.com', - publicKey: 'mysuperpublickey' - } + url: 'http://coucou.com', + publicKey: 'mysuperpublickey' } makePostBodyRequest(path, data, done, false) }) diff --git a/server/tests/api/friendsAdvanced.js b/server/tests/api/friendsAdvanced.js index 86620254e..b082270ff 100644 --- a/server/tests/api/friendsAdvanced.js +++ b/server/tests/api/friendsAdvanced.js @@ -130,6 +130,18 @@ describe('Test advanced friends', function () { function (next) { makeFriends(4, next) }, + // Check the pods 1, 2, 3 and 4 are friends + function (next) { + async.each([ 1, 2, 3, 4 ], function (i, callback) { + getFriendsList(i, function (err, res) { + if (err) throw err + + expect(res.body.length).to.equal(3) + + callback() + }) + }, next) + }, // Kill pod 4 function (next) { servers[3].app.kill() @@ -152,7 +164,7 @@ describe('Test advanced friends', function () { uploadVideo(2, next) }, function (next) { - setTimeout(next, 20000) + setTimeout(next, 11000) }, // Rerun server 4 function (next) { @@ -173,6 +185,9 @@ describe('Test advanced friends', function () { // Pod 6 ask pod 1, 2 and 3 function (next) { makeFriends(6, next) + }, + function (next) { + setTimeout(next, 11000) }], function (err) { if (err) throw err @@ -247,7 +262,7 @@ describe('Test advanced friends', function () { done() }) - }, 5000) + }, 11000) }) }) diff --git a/server/tests/api/friendsBasic.js b/server/tests/api/friendsBasic.js index 68817e852..5b738ad39 100644 --- a/server/tests/api/friendsBasic.js +++ b/server/tests/api/friendsBasic.js @@ -25,9 +25,10 @@ describe('Test basic friends', function () { if (err) throw err const result = res.body - const resultUrls = [ result[0].url, result[1].url ] expect(result).to.be.an('array') expect(result.length).to.equal(2) + + const resultUrls = [ result[0].url, result[1].url ] expect(resultUrls[0]).to.not.equal(resultUrls[1]) const errorString = 'Friends url do not correspond for ' + serverToTest.url diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js index 40326c260..2a1bc64e6 100644 --- a/server/tests/api/multiplePods.js +++ b/server/tests/api/multiplePods.js @@ -105,6 +105,7 @@ describe('Test multiple pods', function () { expect(video.duration).to.equal(10) expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) expect(utils.dateIsValid(video.createdDate)).to.be.true + expect(video.author).to.equal('root') if (server.url !== 'http://localhost:9001') { expect(video.isLocal).to.be.false @@ -166,6 +167,7 @@ describe('Test multiple pods', function () { expect(video.duration).to.equal(5) expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) expect(utils.dateIsValid(video.createdDate)).to.be.true + expect(video.author).to.equal('root') if (server.url !== 'http://localhost:9002') { expect(video.isLocal).to.be.false @@ -243,6 +245,7 @@ describe('Test multiple pods', function () { expect(video1.magnetUri).to.exist expect(video1.duration).to.equal(5) expect(video1.tags).to.deep.equal([ 'tag1p3' ]) + expect(video1.author).to.equal('root') expect(utils.dateIsValid(video1.createdDate)).to.be.true expect(video2.name).to.equal('my super name for pod 3-2') @@ -251,6 +254,7 @@ describe('Test multiple pods', function () { expect(video2.magnetUri).to.exist expect(video2.duration).to.equal(5) expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) + expect(video2.author).to.equal('root') expect(utils.dateIsValid(video2.createdDate)).to.be.true if (server.url !== 'http://localhost:9003') { -- cgit v1.2.3