]>
git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - test/api/friendsAdvanced.js
4 var chai
= require('chai')
5 var expect
= chai
.expect
7 var utils
= require('./utils')
9 describe('Test advanced friends', function () {
13 function makeFriend (pod_number
, callback
) {
14 return utils
.makeFriend(urls
[pod_number
- 1], callback
)
17 function getFriendsList (pod_number
, end
) {
18 return utils
.getFriendsList(urls
[pod_number
- 1], end
)
21 function uploadVideo (pod_number
, callback
) {
22 var name
= 'my super video'
23 var description
= 'my super description'
24 var fixture
= 'video_short.webm'
26 return utils
.uploadVideo(urls
[pod_number
- 1], name
, description
, fixture
, callback
)
29 beforeEach(function (done
) {
31 utils
.runMultipleServers(6, function (apps_run
, urls_run
) {
38 afterEach(function (done
) {
39 apps
.forEach(function (app
) {
40 process
.kill(-app
.pid
)
44 utils
.flushTests(function () {
52 it('Should make friends with two pod each in a different group', function (done
) {
55 // Pod 3 makes friend with the first one
56 makeFriend(3, function () {
57 // Pod 4 makes friend with the second one
58 makeFriend(4, function () {
59 // Now if the fifth wants to make friends with the third et the first
60 makeFriend(5, function () {
61 // It should have 0 friends
62 getFriendsList(5, function (err
, res
) {
65 expect(res
.body
.length
).to
.equal(0)
74 it('Should make friends with the pods 1, 2, 3', function (done
) {
77 // Pods 1, 2, 3 and 4 become friends (yes this is beautiful)
78 makeFriend(2, function () {
79 makeFriend(1, function () {
80 makeFriend(4, function () {
84 // Expulse pod 4 from pod 1 and 2
85 uploadVideo(1, function () {
86 setTimeout(function () {
87 uploadVideo(1, function () {
88 setTimeout(function () {
89 uploadVideo(2, function () {
90 setTimeout(function () {
91 uploadVideo(2, function () {
92 setTimeout(function () {
94 utils
.runServer(4, function (app
, url
) {
96 getFriendsList(4, function (err
, res
) {
98 // Pod 4 didn't know pod 1 and 2 removed it
99 expect(res
.body
.length
).to
.equal(3)
101 // Pod 6 ask pod 1, 2 and 3
102 makeFriend(6, function () {
103 getFriendsList(6, function (err
, res
) {
106 // Pod 4 should not be our friend
107 var result
= res
.body
108 expect(result
.length
).to
.equal(3)
109 for (var pod
of result
) {
110 expect(pod
.url
).not
.equal(urls
[3])