diff options
author | Green-Star <Green-Star@users.noreply.github.com> | 2017-08-02 21:50:42 +0200 |
---|---|---|
committer | Bigard Florian <florian.bigard@gmail.com> | 2017-08-02 21:50:42 +0200 |
commit | d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f (patch) | |
tree | bc945e1b6ab0f9cb36a481fea56cdfdaa8b1a341 /server/tests/api/friends-advanced.js | |
parent | 291e8d3eed88fe714fb74ad897ac2c67347a85ff (diff) | |
download | PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.gz PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.tar.zst PeerTube-d5f5a670fcf6258d0facf9a2fd3aabd550fbc78f.zip |
Remove one pod (#76)
* Client: Fix typo
* Client: Add removeFriend feature
* Server: Add removeFriend feature
* Server: Update method name
* Fix rebase onto develop issues
* Server: Fix error message
* Server: Remove useless methods in removeFriend method
* Server: Finish remove on pod feature after rebase
* Server: Type pod parameter
* Fix Travis build
* Add friend-basic test for the remove one pod feature
* Add check-params tests for the remove one pod feature
* Fix typos
* Add friend-advanced test for the remove one pod feature
* Client: Trailing new line
* Move to promises
* Add undefined id test
* Use find method instead of a for loop to find the friend to remove
* Remove setTimeout method
* Server: Remove requestScheduler operations
* Server: Fix logging messages
* Server: Remove sign request parameter
Diffstat (limited to 'server/tests/api/friends-advanced.js')
-rw-r--r-- | server/tests/api/friends-advanced.js | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/server/tests/api/friends-advanced.js b/server/tests/api/friends-advanced.js index 917583a42..89dc080bc 100644 --- a/server/tests/api/friends-advanced.js +++ b/server/tests/api/friends-advanced.js | |||
@@ -25,6 +25,20 @@ describe('Test advanced friends', function () { | |||
25 | return podsUtils.quitFriends(server.url, server.accessToken, callback) | 25 | return podsUtils.quitFriends(server.url, server.accessToken, callback) |
26 | } | 26 | } |
27 | 27 | ||
28 | function removeFriend (podNumber, podNumberToRemove, callback) { | ||
29 | const server = servers[podNumber - 1] | ||
30 | const serverToRemove = servers[podNumberToRemove - 1] | ||
31 | |||
32 | getFriendsList(podNumber, function (err, res) { | ||
33 | if (err) throw err | ||
34 | |||
35 | let friendsList = res.body.data | ||
36 | let podToRemove = friendsList.find((friend) => (friend.host === serverToRemove.host)) | ||
37 | |||
38 | return podsUtils.quitOneFriend(server.url, server.accessToken, podToRemove.id, callback) | ||
39 | }) | ||
40 | } | ||
41 | |||
28 | function getFriendsList (podNumber, end) { | 42 | function getFriendsList (podNumber, end) { |
29 | const server = servers[podNumber - 1] | 43 | const server = servers[podNumber - 1] |
30 | return podsUtils.getFriendsList(server.url, end) | 44 | return podsUtils.getFriendsList(server.url, end) |
@@ -288,6 +302,84 @@ describe('Test advanced friends', function () { | |||
288 | }) | 302 | }) |
289 | }) | 303 | }) |
290 | 304 | ||
305 | it('Should allow pod 6 to quit pod 1 & 2 and be friend with pod 3', function (done) { | ||
306 | this.timeout(30000) | ||
307 | |||
308 | series([ | ||
309 | // Pod 3 should have 4 friends | ||
310 | function (next) { | ||
311 | getFriendsList(3, function (err, res) { | ||
312 | if (err) throw err | ||
313 | |||
314 | const friendsList = res.body.data | ||
315 | expect(friendsList).to.be.an('array') | ||
316 | expect(friendsList.length).to.equal(4) | ||
317 | |||
318 | next() | ||
319 | }) | ||
320 | }, | ||
321 | // Pod 1, 2, 6 should have 3 friends each | ||
322 | function (next) { | ||
323 | each([ 1, 2, 6 ], function (i, callback) { | ||
324 | getFriendsList(i, function (err, res) { | ||
325 | if (err) throw err | ||
326 | |||
327 | const friendsList = res.body.data | ||
328 | expect(friendsList).to.be.an('array') | ||
329 | expect(friendsList.length).to.equal(3) | ||
330 | |||
331 | callback() | ||
332 | }) | ||
333 | }, next) | ||
334 | }, | ||
335 | function (next) { | ||
336 | removeFriend(6, 1, next) | ||
337 | }, | ||
338 | function (next) { | ||
339 | removeFriend(6, 2, next) | ||
340 | }, | ||
341 | // Pod 6 should now have only 1 friend (and it should be Pod 3) | ||
342 | function (next) { | ||
343 | getFriendsList(6, function (err, res) { | ||
344 | if (err) throw err | ||
345 | |||
346 | const friendsList = res.body.data | ||
347 | expect(friendsList).to.be.an('array') | ||
348 | expect(friendsList.length).to.equal(1) | ||
349 | expect(friendsList[0].host).to.equal(servers[2].host) | ||
350 | |||
351 | next() | ||
352 | }) | ||
353 | }, | ||
354 | // Pod 1 & 2 should not know friend 6 anymore | ||
355 | function (next) { | ||
356 | each([ 1, 2 ], function (i, callback) { | ||
357 | getFriendsList(i, function (err, res) { | ||
358 | if (err) throw err | ||
359 | |||
360 | const friendsList = res.body.data | ||
361 | expect(friendsList).to.be.an('array') | ||
362 | expect(friendsList.length).to.equal(2) | ||
363 | |||
364 | callback() | ||
365 | }) | ||
366 | }, next) | ||
367 | }, | ||
368 | // Pod 3 should know every pod | ||
369 | function (next) { | ||
370 | getFriendsList(3, function (err, res) { | ||
371 | if (err) throw err | ||
372 | |||
373 | const friendsList = res.body.data | ||
374 | expect(friendsList).to.be.an('array') | ||
375 | expect(friendsList.length).to.equal(4) | ||
376 | |||
377 | next() | ||
378 | }) | ||
379 | } | ||
380 | ], done) | ||
381 | }) | ||
382 | |||
291 | after(function (done) { | 383 | after(function (done) { |
292 | servers.forEach(function (server) { | 384 | servers.forEach(function (server) { |
293 | process.kill(-server.app.pid) | 385 | process.kill(-server.app.pid) |