aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/api/utils.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-01-24 16:08:09 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-01-24 16:08:09 +0100
commitee66c5930e6c3694434a259dfb4b7f3e9f39cf7b (patch)
treea880612dca3247fde962417077680ea34cc96d20 /test/api/utils.js
parent45239549bf2659998dcf9196d86974b0b625912e (diff)
downloadPeerTube-ee66c5930e6c3694434a259dfb4b7f3e9f39cf7b.tar.gz
PeerTube-ee66c5930e6c3694434a259dfb4b7f3e9f39cf7b.tar.zst
PeerTube-ee66c5930e6c3694434a259dfb4b7f3e9f39cf7b.zip
Tests refractoring
Diffstat (limited to 'test/api/utils.js')
-rw-r--r--test/api/utils.js64
1 files changed, 30 insertions, 34 deletions
diff --git a/test/api/utils.js b/test/api/utils.js
index b00890539..afb0abb33 100644
--- a/test/api/utils.js
+++ b/test/api/utils.js
@@ -6,10 +6,23 @@
6 var fork = child_process.fork 6 var fork = child_process.fork
7 var request = require('supertest') 7 var request = require('supertest')
8 8
9 module.exports = {
10 flushTests: flushTests,
11 getFriendsList: getFriendsList,
12 getVideosList: getVideosList,
13 makeFriends: makeFriends,
14 quitFriends: quitFriends,
15 removeVideo: removeVideo,
16 flushAndRunMultipleServers: flushAndRunMultipleServers,
17 runServer: runServer,
18 searchVideo: searchVideo,
19 uploadVideo: uploadVideo
20 }
21
22 // ---------------------- Export functions --------------------
23
9 function flushTests (callback) { 24 function flushTests (callback) {
10 exec(__dirname + '/../../scripts/clean_test.sh', function () { 25 exec(__dirname + '/../../scripts/clean_test.sh', callback)
11 callback()
12 })
13 } 26 }
14 27
15 function getFriendsList (url, end) { 28 function getFriendsList (url, end) {
@@ -51,9 +64,7 @@
51 if (err) throw err 64 if (err) throw err
52 65
53 // Wait for the request between pods 66 // Wait for the request between pods
54 setTimeout(function () { 67 setTimeout(callback, 1000)
55 callback()
56 }, 1000)
57 }) 68 })
58 } 69 }
59 70
@@ -69,25 +80,10 @@
69 if (err) throw err 80 if (err) throw err
70 81
71 // Wait for the request between pods 82 // Wait for the request between pods
72 setTimeout(function () { 83 setTimeout(callback, 1000)
73 callback()
74 }, 1000)
75 }) 84 })
76 } 85 }
77 86
78 function uploadVideo (url, name, description, fixture, end) {
79 var path = '/api/v1/videos'
80
81 request(url)
82 .post(path)
83 .set('Accept', 'application/json')
84 .field('name', name)
85 .field('description', description)
86 .attach('input_video', __dirname + '/fixtures/' + fixture)
87 .expect(201)
88 .end(end)
89 }
90
91 function removeVideo (url, id, end) { 87 function removeVideo (url, id, end) {
92 var path = '/api/v1/videos' 88 var path = '/api/v1/videos'
93 89
@@ -98,7 +94,7 @@
98 .end(end) 94 .end(end)
99 } 95 }
100 96
101 function runMultipleServers (total_servers, serversRun) { 97 function flushAndRunMultipleServers (total_servers, serversRun) {
102 var apps = [] 98 var apps = []
103 var urls = [] 99 var urls = []
104 var i = 0 100 var i = 0
@@ -171,16 +167,16 @@
171 .end(end) 167 .end(end)
172 } 168 }
173 169
174 module.exports = { 170 function uploadVideo (url, name, description, fixture, end) {
175 flushTests: flushTests, 171 var path = '/api/v1/videos'
176 getFriendsList: getFriendsList, 172
177 getVideosList: getVideosList, 173 request(url)
178 makeFriends: makeFriends, 174 .post(path)
179 quitFriends: quitFriends, 175 .set('Accept', 'application/json')
180 removeVideo: removeVideo, 176 .field('name', name)
181 runMultipleServers: runMultipleServers, 177 .field('description', description)
182 runServer: runServer, 178 .attach('input_video', __dirname + '/fixtures/' + fixture)
183 searchVideo: searchVideo, 179 .expect(201)
184 uploadVideo: uploadVideo 180 .end(end)
185 } 181 }
186})() 182})()