diff options
Diffstat (limited to 'server/tests/api/friendsAdvanced.js')
-rw-r--r-- | server/tests/api/friendsAdvanced.js | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/server/tests/api/friendsAdvanced.js b/server/tests/api/friendsAdvanced.js index 6c4b7567f..6f18648d7 100644 --- a/server/tests/api/friendsAdvanced.js +++ b/server/tests/api/friendsAdvanced.js | |||
@@ -7,41 +7,48 @@ const expect = chai.expect | |||
7 | const utils = require('./utils') | 7 | const utils = require('./utils') |
8 | 8 | ||
9 | describe('Test advanced friends', function () { | 9 | describe('Test advanced friends', function () { |
10 | let apps = [] | 10 | let servers = [] |
11 | let urls = [] | ||
12 | 11 | ||
13 | function makeFriends (pod_number, callback) { | 12 | function makeFriends (pod_number, callback) { |
14 | return utils.makeFriends(urls[pod_number - 1], callback) | 13 | return utils.makeFriends(servers[pod_number - 1].url, callback) |
15 | } | 14 | } |
16 | 15 | ||
17 | function quitFriends (pod_number, callback) { | 16 | function quitFriends (pod_number, callback) { |
18 | return utils.quitFriends(urls[pod_number - 1], callback) | 17 | return utils.quitFriends(servers[pod_number - 1].url, callback) |
19 | } | 18 | } |
20 | 19 | ||
21 | function getFriendsList (pod_number, end) { | 20 | function getFriendsList (pod_number, end) { |
22 | return utils.getFriendsList(urls[pod_number - 1], end) | 21 | return utils.getFriendsList(servers[pod_number - 1].url, end) |
23 | } | 22 | } |
24 | 23 | ||
25 | function uploadVideo (pod_number, callback) { | 24 | function uploadVideo (pod_number, callback) { |
26 | const name = 'my super video' | 25 | const name = 'my super video' |
27 | const description = 'my super description' | 26 | const description = 'my super description' |
28 | const fixture = 'video_short.webm' | 27 | const fixture = 'video_short.webm' |
28 | const server = servers[pod_number - 1] | ||
29 | 29 | ||
30 | return utils.uploadVideo(urls[pod_number - 1], name, description, fixture, callback) | 30 | return utils.uploadVideo(server.url, server.access_token, name, description, fixture, callback) |
31 | } | 31 | } |
32 | 32 | ||
33 | function getVideos (pod_number, callback) { | 33 | function getVideos (pod_number, callback) { |
34 | return utils.getVideosList(urls[pod_number - 1], callback) | 34 | return utils.getVideosList(servers[pod_number - 1].url, callback) |
35 | } | 35 | } |
36 | 36 | ||
37 | // --------------------------------------------------------------- | 37 | // --------------------------------------------------------------- |
38 | 38 | ||
39 | before(function (done) { | 39 | before(function (done) { |
40 | this.timeout(30000) | 40 | this.timeout(30000) |
41 | utils.flushAndRunMultipleServers(6, function (apps_run, urls_run) { | 41 | utils.flushAndRunMultipleServers(6, function (servers_run, urls_run) { |
42 | apps = apps_run | 42 | servers = servers_run |
43 | urls = urls_run | 43 | |
44 | done() | 44 | async.each(servers, function (server, callback_each) { |
45 | utils.loginAndGetAccessToken(server, function (err, access_token) { | ||
46 | if (err) return callback_each(err) | ||
47 | |||
48 | server.access_token = access_token | ||
49 | callback_each() | ||
50 | }) | ||
51 | }, done) | ||
45 | }) | 52 | }) |
46 | }) | 53 | }) |
47 | 54 | ||
@@ -121,7 +128,7 @@ describe('Test advanced friends', function () { | |||
121 | }, | 128 | }, |
122 | // Kill pod 4 | 129 | // Kill pod 4 |
123 | function (next) { | 130 | function (next) { |
124 | apps[3].kill() | 131 | servers[3].app.kill() |
125 | next() | 132 | next() |
126 | }, | 133 | }, |
127 | // Expulse pod 4 from pod 1 and 2 | 134 | // Expulse pod 4 from pod 1 and 2 |
@@ -145,8 +152,8 @@ describe('Test advanced friends', function () { | |||
145 | }, | 152 | }, |
146 | // Rerun server 4 | 153 | // Rerun server 4 |
147 | function (next) { | 154 | function (next) { |
148 | utils.runServer(4, function (app, url) { | 155 | utils.runServer(4, function (server) { |
149 | apps[3] = app | 156 | servers[3].app = server.app |
150 | next() | 157 | next() |
151 | }) | 158 | }) |
152 | }, | 159 | }, |
@@ -156,7 +163,6 @@ describe('Test advanced friends', function () { | |||
156 | 163 | ||
157 | // Pod 4 didn't know pod 1 and 2 removed it | 164 | // Pod 4 didn't know pod 1 and 2 removed it |
158 | expect(res.body.length).to.equal(3) | 165 | expect(res.body.length).to.equal(3) |
159 | |||
160 | next() | 166 | next() |
161 | }) | 167 | }) |
162 | }, | 168 | }, |
@@ -174,7 +180,7 @@ describe('Test advanced friends', function () { | |||
174 | const result = res.body | 180 | const result = res.body |
175 | expect(result.length).to.equal(3) | 181 | expect(result.length).to.equal(3) |
176 | for (const pod of result) { | 182 | for (const pod of result) { |
177 | expect(pod.url).not.equal(urls[3]) | 183 | expect(pod.url).not.equal(servers[3].url) |
178 | } | 184 | } |
179 | 185 | ||
180 | done() | 186 | done() |
@@ -237,8 +243,8 @@ describe('Test advanced friends', function () { | |||
237 | }) | 243 | }) |
238 | 244 | ||
239 | after(function (done) { | 245 | after(function (done) { |
240 | apps.forEach(function (app) { | 246 | servers.forEach(function (server) { |
241 | process.kill(-app.pid) | 247 | process.kill(-server.app.pid) |
242 | }) | 248 | }) |
243 | 249 | ||
244 | if (this.ok) { | 250 | if (this.ok) { |