1 import * as request from 'supertest'
3 import { wait } from './miscs'
5 function getFriendsList (url: string) {
6 const path = '/api/v1/pods/'
10 .set('Accept', 'application/json')
12 .expect('Content-Type', /json/)
15 function getPodsListPaginationAndSort (url: string, start: number, count: number, sort: string) {
16 const path = '/api/v1/pods/'
23 .set('Accept', 'application/json')
25 .expect('Content-Type', /json/)
28 async function makeFriends (url: string, accessToken: string, expectedStatus = 204) {
29 // Which pod makes friends with which pod
30 const friendsMatrix = {
31 'http://localhost:9001': [
34 'http://localhost:9002': [
37 'http://localhost:9003': [
40 'http://localhost:9004': [
43 'http://localhost:9005': [
47 'http://localhost:9006': [
53 const path = '/api/v1/pods/make-friends'
55 // The first pod make friend with the third
56 const res = await request(url)
58 .set('Accept', 'application/json')
59 .set('Authorization', 'Bearer ' + accessToken)
60 .send({ 'hosts': friendsMatrix[url] })
61 .expect(expectedStatus)
63 // Wait request propagation
69 async function quitFriends (url: string, accessToken: string, expectedStatus = 204) {
70 const path = '/api/v1/pods/quit-friends'
72 // The first pod make friend with the third
73 const res = await request(url)
75 .set('Accept', 'application/json')
76 .set('Authorization', 'Bearer ' + accessToken)
77 .expect(expectedStatus)
79 // Wait request propagation
85 function quitOneFriend (url: string, accessToken: string, friendId: number, expectedStatus = 204) {
86 const path = '/api/v1/pods/' + friendId
90 .set('Accept', 'application/json')
91 .set('Authorization', 'Bearer ' + accessToken)
92 .expect(expectedStatus)
95 // ---------------------------------------------------------------------------
102 getPodsListPaginationAndSort