aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/friendsBasic.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/friendsBasic.js')
-rw-r--r--server/tests/api/friendsBasic.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/server/tests/api/friendsBasic.js b/server/tests/api/friendsBasic.js
index c74a7f224..2a6883acb 100644
--- a/server/tests/api/friendsBasic.js
+++ b/server/tests/api/friendsBasic.js
@@ -5,14 +5,16 @@ const each = require('async/each')
5const expect = chai.expect 5const expect = chai.expect
6const series = require('async/series') 6const series = require('async/series')
7 7
8const utils = require('./utils') 8const loginUtils = require('../utils/login')
9const podsUtils = require('../utils/pods')
10const serversUtils = require('../utils/servers')
9 11
10describe('Test basic friends', function () { 12describe('Test basic friends', function () {
11 let servers = [] 13 let servers = []
12 14
13 function makeFriends (podNumber, callback) { 15 function makeFriends (podNumber, callback) {
14 const server = servers[podNumber - 1] 16 const server = servers[podNumber - 1]
15 return utils.makeFriends(server.url, server.accessToken, callback) 17 return podsUtils.makeFriends(server.url, server.accessToken, callback)
16 } 18 }
17 19
18 function testMadeFriends (servers, serverToTest, callback) { 20 function testMadeFriends (servers, serverToTest, callback) {
@@ -22,7 +24,7 @@ describe('Test basic friends', function () {
22 friends.push(servers[i].url) 24 friends.push(servers[i].url)
23 } 25 }
24 26
25 utils.getFriendsList(serverToTest.url, function (err, res) { 27 podsUtils.getFriendsList(serverToTest.url, function (err, res) {
26 if (err) throw err 28 if (err) throw err
27 29
28 const result = res.body 30 const result = res.body
@@ -43,11 +45,11 @@ describe('Test basic friends', function () {
43 45
44 before(function (done) { 46 before(function (done) {
45 this.timeout(20000) 47 this.timeout(20000)
46 utils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) { 48 serversUtils.flushAndRunMultipleServers(3, function (serversRun, urlsRun) {
47 servers = serversRun 49 servers = serversRun
48 50
49 each(servers, function (server, callbackEach) { 51 each(servers, function (server, callbackEach) {
50 utils.loginAndGetAccessToken(server, function (err, accessToken) { 52 loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
51 if (err) return callbackEach(err) 53 if (err) return callbackEach(err)
52 54
53 server.accessToken = accessToken 55 server.accessToken = accessToken
@@ -59,7 +61,7 @@ describe('Test basic friends', function () {
59 61
60 it('Should not have friends', function (done) { 62 it('Should not have friends', function (done) {
61 each(servers, function (server, callback) { 63 each(servers, function (server, callback) {
62 utils.getFriendsList(server.url, function (err, res) { 64 podsUtils.getFriendsList(server.url, function (err, res) {
63 if (err) throw err 65 if (err) throw err
64 66
65 const result = res.body 67 const result = res.body
@@ -84,7 +86,7 @@ describe('Test basic friends', function () {
84 }, 86 },
85 // The second pod should have the third as a friend 87 // The second pod should have the third as a friend
86 function (next) { 88 function (next) {
87 utils.getFriendsList(servers[1].url, function (err, res) { 89 podsUtils.getFriendsList(servers[1].url, function (err, res) {
88 if (err) throw err 90 if (err) throw err
89 91
90 const result = res.body 92 const result = res.body
@@ -97,7 +99,7 @@ describe('Test basic friends', function () {
97 }, 99 },
98 // Same here, the third pod should have the second pod as a friend 100 // Same here, the third pod should have the second pod as a friend
99 function (next) { 101 function (next) {
100 utils.getFriendsList(servers[2].url, function (err, res) { 102 podsUtils.getFriendsList(servers[2].url, function (err, res) {
101 if (err) throw err 103 if (err) throw err
102 104
103 const result = res.body 105 const result = res.body
@@ -128,7 +130,7 @@ describe('Test basic friends', function () {
128 130
129 it('Should not be allowed to make friend again', function (done) { 131 it('Should not be allowed to make friend again', function (done) {
130 const server = servers[1] 132 const server = servers[1]
131 utils.makeFriends(server.url, server.accessToken, 409, done) 133 podsUtils.makeFriends(server.url, server.accessToken, 409, done)
132 }) 134 })
133 135
134 it('Should quit friends of pod 2', function (done) { 136 it('Should quit friends of pod 2', function (done) {
@@ -136,11 +138,11 @@ describe('Test basic friends', function () {
136 // Pod 1 quit friends 138 // Pod 1 quit friends
137 function (next) { 139 function (next) {
138 const server = servers[1] 140 const server = servers[1]
139 utils.quitFriends(server.url, server.accessToken, next) 141 podsUtils.quitFriends(server.url, server.accessToken, next)
140 }, 142 },
141 // Pod 1 should not have friends anymore 143 // Pod 1 should not have friends anymore
142 function (next) { 144 function (next) {
143 utils.getFriendsList(servers[1].url, function (err, res) { 145 podsUtils.getFriendsList(servers[1].url, function (err, res) {
144 if (err) throw err 146 if (err) throw err
145 147
146 const result = res.body 148 const result = res.body
@@ -153,7 +155,7 @@ describe('Test basic friends', function () {
153 // Other pods shouldn't have pod 1 too 155 // Other pods shouldn't have pod 1 too
154 function (next) { 156 function (next) {
155 each([ servers[0].url, servers[2].url ], function (url, callback) { 157 each([ servers[0].url, servers[2].url ], function (url, callback) {
156 utils.getFriendsList(url, function (err, res) { 158 podsUtils.getFriendsList(url, function (err, res) {
157 if (err) throw err 159 if (err) throw err
158 160
159 const result = res.body 161 const result = res.body
@@ -169,7 +171,7 @@ describe('Test basic friends', function () {
169 171
170 it('Should allow pod 2 to make friend again', function (done) { 172 it('Should allow pod 2 to make friend again', function (done) {
171 const server = servers[1] 173 const server = servers[1]
172 utils.makeFriends(server.url, server.accessToken, function () { 174 podsUtils.makeFriends(server.url, server.accessToken, function () {
173 each(servers, function (server, callback) { 175 each(servers, function (server, callback) {
174 testMadeFriends(servers, server, callback) 176 testMadeFriends(servers, server, callback)
175 }, done) 177 }, done)
@@ -182,7 +184,7 @@ describe('Test basic friends', function () {
182 }) 184 })
183 185
184 if (this.ok) { 186 if (this.ok) {
185 utils.flushTests(done) 187 serversUtils.flushTests(done)
186 } else { 188 } else {
187 done() 189 done()
188 } 190 }