aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/checkParams.js24
-rw-r--r--server/tests/api/friendsAdvanced.js19
-rw-r--r--server/tests/api/friendsBasic.js3
-rw-r--r--server/tests/api/multiplePods.js4
4 files changed, 31 insertions, 19 deletions
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 () {
90 90
91 it('Should fail without public key', function (done) { 91 it('Should fail without public key', function (done) {
92 const data = { 92 const data = {
93 data: { 93 url: 'http://coucou.com'
94 url: 'http://coucou.com'
95 }
96 } 94 }
97 makePostBodyRequest(path, data, done) 95 makePostBodyRequest(path, data, done)
98 }) 96 })
99 97
100 it('Should fail without an url', function (done) { 98 it('Should fail without an url', function (done) {
101 const data = { 99 const data = {
102 data: { 100 publicKey: 'mysuperpublickey'
103 publicKey: 'mysuperpublickey'
104 }
105 } 101 }
106 makePostBodyRequest(path, data, done) 102 makePostBodyRequest(path, data, done)
107 }) 103 })
108 104
109 it('Should fail with an incorrect url', function (done) { 105 it('Should fail with an incorrect url', function (done) {
110 const data = { 106 const data = {
111 data: { 107 url: 'coucou.com',
112 url: 'coucou.com', 108 publicKey: 'mysuperpublickey'
113 publicKey: 'mysuperpublickey'
114 }
115 } 109 }
116 makePostBodyRequest(path, data, function () { 110 makePostBodyRequest(path, data, function () {
117 data.data.url = 'http://coucou' 111 data.url = 'http://coucou'
118 makePostBodyRequest(path, data, function () { 112 makePostBodyRequest(path, data, function () {
119 data.data.url = 'coucou' 113 data.url = 'coucou'
120 makePostBodyRequest(path, data, done) 114 makePostBodyRequest(path, data, done)
121 }) 115 })
122 }) 116 })
@@ -124,10 +118,8 @@ describe('Test parameters validator', function () {
124 118
125 it('Should succeed with the correct parameters', function (done) { 119 it('Should succeed with the correct parameters', function (done) {
126 const data = { 120 const data = {
127 data: { 121 url: 'http://coucou.com',
128 url: 'http://coucou.com', 122 publicKey: 'mysuperpublickey'
129 publicKey: 'mysuperpublickey'
130 }
131 } 123 }
132 makePostBodyRequest(path, data, done, false) 124 makePostBodyRequest(path, data, done, false)
133 }) 125 })
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 () {
130 function (next) { 130 function (next) {
131 makeFriends(4, next) 131 makeFriends(4, next)
132 }, 132 },
133 // Check the pods 1, 2, 3 and 4 are friends
134 function (next) {
135 async.each([ 1, 2, 3, 4 ], function (i, callback) {
136 getFriendsList(i, function (err, res) {
137 if (err) throw err
138
139 expect(res.body.length).to.equal(3)
140
141 callback()
142 })
143 }, next)
144 },
133 // Kill pod 4 145 // Kill pod 4
134 function (next) { 146 function (next) {
135 servers[3].app.kill() 147 servers[3].app.kill()
@@ -152,7 +164,7 @@ describe('Test advanced friends', function () {
152 uploadVideo(2, next) 164 uploadVideo(2, next)
153 }, 165 },
154 function (next) { 166 function (next) {
155 setTimeout(next, 20000) 167 setTimeout(next, 11000)
156 }, 168 },
157 // Rerun server 4 169 // Rerun server 4
158 function (next) { 170 function (next) {
@@ -173,6 +185,9 @@ describe('Test advanced friends', function () {
173 // Pod 6 ask pod 1, 2 and 3 185 // Pod 6 ask pod 1, 2 and 3
174 function (next) { 186 function (next) {
175 makeFriends(6, next) 187 makeFriends(6, next)
188 },
189 function (next) {
190 setTimeout(next, 11000)
176 }], 191 }],
177 function (err) { 192 function (err) {
178 if (err) throw err 193 if (err) throw err
@@ -247,7 +262,7 @@ describe('Test advanced friends', function () {
247 262
248 done() 263 done()
249 }) 264 })
250 }, 5000) 265 }, 11000)
251 }) 266 })
252 }) 267 })
253 268
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 () {
25 if (err) throw err 25 if (err) throw err
26 26
27 const result = res.body 27 const result = res.body
28 const resultUrls = [ result[0].url, result[1].url ]
29 expect(result).to.be.an('array') 28 expect(result).to.be.an('array')
30 expect(result.length).to.equal(2) 29 expect(result.length).to.equal(2)
30
31 const resultUrls = [ result[0].url, result[1].url ]
31 expect(resultUrls[0]).to.not.equal(resultUrls[1]) 32 expect(resultUrls[0]).to.not.equal(resultUrls[1])
32 33
33 const errorString = 'Friends url do not correspond for ' + serverToTest.url 34 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 () {
105 expect(video.duration).to.equal(10) 105 expect(video.duration).to.equal(10)
106 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) 106 expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ])
107 expect(utils.dateIsValid(video.createdDate)).to.be.true 107 expect(utils.dateIsValid(video.createdDate)).to.be.true
108 expect(video.author).to.equal('root')
108 109
109 if (server.url !== 'http://localhost:9001') { 110 if (server.url !== 'http://localhost:9001') {
110 expect(video.isLocal).to.be.false 111 expect(video.isLocal).to.be.false
@@ -166,6 +167,7 @@ describe('Test multiple pods', function () {
166 expect(video.duration).to.equal(5) 167 expect(video.duration).to.equal(5)
167 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) 168 expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ])
168 expect(utils.dateIsValid(video.createdDate)).to.be.true 169 expect(utils.dateIsValid(video.createdDate)).to.be.true
170 expect(video.author).to.equal('root')
169 171
170 if (server.url !== 'http://localhost:9002') { 172 if (server.url !== 'http://localhost:9002') {
171 expect(video.isLocal).to.be.false 173 expect(video.isLocal).to.be.false
@@ -243,6 +245,7 @@ describe('Test multiple pods', function () {
243 expect(video1.magnetUri).to.exist 245 expect(video1.magnetUri).to.exist
244 expect(video1.duration).to.equal(5) 246 expect(video1.duration).to.equal(5)
245 expect(video1.tags).to.deep.equal([ 'tag1p3' ]) 247 expect(video1.tags).to.deep.equal([ 'tag1p3' ])
248 expect(video1.author).to.equal('root')
246 expect(utils.dateIsValid(video1.createdDate)).to.be.true 249 expect(utils.dateIsValid(video1.createdDate)).to.be.true
247 250
248 expect(video2.name).to.equal('my super name for pod 3-2') 251 expect(video2.name).to.equal('my super name for pod 3-2')
@@ -251,6 +254,7 @@ describe('Test multiple pods', function () {
251 expect(video2.magnetUri).to.exist 254 expect(video2.magnetUri).to.exist
252 expect(video2.duration).to.equal(5) 255 expect(video2.duration).to.equal(5)
253 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ]) 256 expect(video2.tags).to.deep.equal([ 'tag2p3', 'tag3p3', 'tag4p3' ])
257 expect(video2.author).to.equal('root')
254 expect(utils.dateIsValid(video2.createdDate)).to.be.true 258 expect(utils.dateIsValid(video2.createdDate)).to.be.true
255 259
256 if (server.url !== 'http://localhost:9003') { 260 if (server.url !== 'http://localhost:9003') {