diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-16 17:16:42 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 4610bc5b12eaa4bfd64fe3fd70c65e5b722aa22d (patch) | |
tree | 42a1deeaf6cd955036213310f4d0171e68b68910 /server/tests/utils/pods.ts | |
parent | 21e0727a84734cb0c81c1c9bb22a49b13e46fe5f (diff) | |
download | PeerTube-4610bc5b12eaa4bfd64fe3fd70c65e5b722aa22d.tar.gz PeerTube-4610bc5b12eaa4bfd64fe3fd70c65e5b722aa22d.tar.zst PeerTube-4610bc5b12eaa4bfd64fe3fd70c65e5b722aa22d.zip |
ApplicationFollow -> SeverFollow
Diffstat (limited to 'server/tests/utils/pods.ts')
-rw-r--r-- | server/tests/utils/pods.ts | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/server/tests/utils/pods.ts b/server/tests/utils/pods.ts deleted file mode 100644 index 52e807e70..000000000 --- a/server/tests/utils/pods.ts +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | |||
3 | import { wait } from './miscs' | ||
4 | |||
5 | function getFriendsList (url: string) { | ||
6 | const path = '/api/v1/pods/' | ||
7 | |||
8 | return request(url) | ||
9 | .get(path) | ||
10 | .set('Accept', 'application/json') | ||
11 | .expect(200) | ||
12 | .expect('Content-Type', /json/) | ||
13 | } | ||
14 | |||
15 | function getPodsListPaginationAndSort (url: string, start: number, count: number, sort: string) { | ||
16 | const path = '/api/v1/pods/' | ||
17 | |||
18 | return request(url) | ||
19 | .get(path) | ||
20 | .query({ start }) | ||
21 | .query({ count }) | ||
22 | .query({ sort }) | ||
23 | .set('Accept', 'application/json') | ||
24 | .expect(200) | ||
25 | .expect('Content-Type', /json/) | ||
26 | } | ||
27 | |||
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': [ | ||
32 | 'localhost:9002' | ||
33 | ], | ||
34 | 'http://localhost:9002': [ | ||
35 | 'localhost:9003' | ||
36 | ], | ||
37 | 'http://localhost:9003': [ | ||
38 | 'localhost:9001' | ||
39 | ], | ||
40 | 'http://localhost:9004': [ | ||
41 | 'localhost:9002' | ||
42 | ], | ||
43 | 'http://localhost:9005': [ | ||
44 | 'localhost:9001', | ||
45 | 'localhost:9004' | ||
46 | ], | ||
47 | 'http://localhost:9006': [ | ||
48 | 'localhost:9001', | ||
49 | 'localhost:9002', | ||
50 | 'localhost:9003' | ||
51 | ] | ||
52 | } | ||
53 | const path = '/api/v1/pods/make-friends' | ||
54 | |||
55 | // The first pod make friend with the third | ||
56 | const res = await request(url) | ||
57 | .post(path) | ||
58 | .set('Accept', 'application/json') | ||
59 | .set('Authorization', 'Bearer ' + accessToken) | ||
60 | .send({ 'hosts': friendsMatrix[url] }) | ||
61 | .expect(expectedStatus) | ||
62 | |||
63 | // Wait request propagation | ||
64 | await wait(1000) | ||
65 | |||
66 | return res | ||
67 | } | ||
68 | |||
69 | async function quitFriends (url: string, accessToken: string, expectedStatus = 204) { | ||
70 | const path = '/api/v1/pods/quit-friends' | ||
71 | |||
72 | // The first pod make friend with the third | ||
73 | const res = await request(url) | ||
74 | .get(path) | ||
75 | .set('Accept', 'application/json') | ||
76 | .set('Authorization', 'Bearer ' + accessToken) | ||
77 | .expect(expectedStatus) | ||
78 | |||
79 | // Wait request propagation | ||
80 | await wait(1000) | ||
81 | |||
82 | return res | ||
83 | } | ||
84 | |||
85 | function quitOneFriend (url: string, accessToken: string, friendId: number, expectedStatus = 204) { | ||
86 | const path = '/api/v1/pods/' + friendId | ||
87 | |||
88 | return request(url) | ||
89 | .delete(path) | ||
90 | .set('Accept', 'application/json') | ||
91 | .set('Authorization', 'Bearer ' + accessToken) | ||
92 | .expect(expectedStatus) | ||
93 | } | ||
94 | |||
95 | // --------------------------------------------------------------------------- | ||
96 | |||
97 | export { | ||
98 | getFriendsList, | ||
99 | makeFriends, | ||
100 | quitFriends, | ||
101 | quitOneFriend, | ||
102 | getPodsListPaginationAndSort | ||
103 | } | ||