3 const request = require('supertest')
12 // ---------------------- Export functions --------------------
14 function getFriendsList (url, end) {
15 const path = '/api/v1/pods/'
19 .set('Accept', 'application/json')
21 .expect('Content-Type', /json/)
25 function makeFriends (url, accessToken, expectedStatus, end) {
31 // Which pod makes friends with which pod
32 const friendsMatrix = {
33 'http://localhost:9001': [
36 'http://localhost:9002': [
39 'http://localhost:9003': [
42 'http://localhost:9004': [
45 'http://localhost:9005': [
49 'http://localhost:9006': [
55 const path = '/api/v1/pods/makefriends'
57 // The first pod make friend with the third
60 .set('Accept', 'application/json')
61 .set('Authorization', 'Bearer ' + accessToken)
62 .send({ 'hosts': friendsMatrix[url] })
63 .expect(expectedStatus)
64 .end(function (err, res) {
67 // Wait for the request between pods
72 function quitFriends (url, accessToken, expectedStatus, end) {
78 const path = '/api/v1/pods/quitfriends'
80 // The first pod make friend with the third
83 .set('Accept', 'application/json')
84 .set('Authorization', 'Bearer ' + accessToken)
85 .expect(expectedStatus)
86 .end(function (err, res) {
89 // Wait for the request between pods
94 function quitOneFriend (url, accessToken, friendId, expectedStatus, end) {
100 const path = '/api/v1/pods/' + friendId
104 .set('Accept', 'application/json')
105 .set('Authorization', 'Bearer ' + accessToken)
106 .expect(expectedStatus)
107 .end(function (err, res) {
114 // ---------------------------------------------------------------------------
116 module.exports = podsUtils