aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/utils.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-11 21:19:34 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-13 14:23:11 +0200
commitbc503c2a62dcf9aed6b8d90b68f0f27a7755ac01 (patch)
treea1fe1ad88afd29ee4d7cb05c480649d5a9c6f9a0 /server/tests/api/utils.js
parent881a5e68b64e4acd43408852bbdc914643d8fac6 (diff)
downloadPeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.gz
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.tar.zst
PeerTube-bc503c2a62dcf9aed6b8d90b68f0f27a7755ac01.zip
Update to standard 7. Goodbye snake_case, I used to love you
Diffstat (limited to 'server/tests/api/utils.js')
-rw-r--r--server/tests/api/utils.js64
1 files changed, 32 insertions, 32 deletions
diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js
index 3d3169fde..45f11ac8f 100644
--- a/server/tests/api/utils.js
+++ b/server/tests/api/utils.js
@@ -1,8 +1,8 @@
1'use strict' 1'use strict'
2 2
3const child_process = require('child_process') 3const childProcess = require('child_process')
4const exec = child_process.exec 4const exec = childProcess.exec
5const fork = child_process.fork 5const fork = childProcess.fork
6const fs = require('fs') 6const fs = require('fs')
7const pathUtils = require('path') 7const pathUtils = require('path')
8const request = require('supertest') 8const request = require('supertest')
@@ -63,10 +63,10 @@ function getVideosList (url, end) {
63 .end(end) 63 .end(end)
64} 64}
65 65
66function login (url, client, user, expected_status, end) { 66function login (url, client, user, expectedStatus, end) {
67 if (!end) { 67 if (!end) {
68 end = expected_status 68 end = expectedStatus
69 expected_status = 200 69 expectedStatus = 200
70 } 70 }
71 71
72 const path = '/api/v1/users/token' 72 const path = '/api/v1/users/token'
@@ -85,7 +85,7 @@ function login (url, client, user, expected_status, end) {
85 .post(path) 85 .post(path)
86 .type('form') 86 .type('form')
87 .send(body) 87 .send(body)
88 .expect(expected_status) 88 .expect(expectedStatus)
89 .end(end) 89 .end(end)
90} 90}
91 91
@@ -97,10 +97,10 @@ function loginAndGetAccessToken (server, callback) {
97 }) 97 })
98} 98}
99 99
100function makeFriends (url, expected_status, callback) { 100function makeFriends (url, expectedStatus, callback) {
101 if (!callback) { 101 if (!callback) {
102 callback = expected_status 102 callback = expectedStatus
103 expected_status = 204 103 expectedStatus = 204
104 } 104 }
105 105
106 const path = '/api/v1/pods/makefriends' 106 const path = '/api/v1/pods/makefriends'
@@ -109,7 +109,7 @@ function makeFriends (url, expected_status, callback) {
109 request(url) 109 request(url)
110 .get(path) 110 .get(path)
111 .set('Accept', 'application/json') 111 .set('Accept', 'application/json')
112 .expect(expected_status) 112 .expect(expectedStatus)
113 .end(function (err, res) { 113 .end(function (err, res) {
114 if (err) throw err 114 if (err) throw err
115 115
@@ -134,10 +134,10 @@ function quitFriends (url, callback) {
134 }) 134 })
135} 135}
136 136
137function removeVideo (url, token, id, expected_status, end) { 137function removeVideo (url, token, id, expectedStatus, end) {
138 if (!end) { 138 if (!end) {
139 end = expected_status 139 end = expectedStatus
140 expected_status = 204 140 expectedStatus = 204
141 } 141 }
142 142
143 const path = '/api/v1/videos' 143 const path = '/api/v1/videos'
@@ -146,11 +146,11 @@ function removeVideo (url, token, id, expected_status, end) {
146 .delete(path + '/' + id) 146 .delete(path + '/' + id)
147 .set('Accept', 'application/json') 147 .set('Accept', 'application/json')
148 .set('Authorization', 'Bearer ' + token) 148 .set('Authorization', 'Bearer ' + token)
149 .expect(expected_status) 149 .expect(expectedStatus)
150 .end(end) 150 .end(end)
151} 151}
152 152
153function flushAndRunMultipleServers (total_servers, serversRun) { 153function flushAndRunMultipleServers (totalServers, serversRun) {
154 let apps = [] 154 let apps = []
155 let urls = [] 155 let urls = []
156 let i = 0 156 let i = 0
@@ -159,13 +159,13 @@ function flushAndRunMultipleServers (total_servers, serversRun) {
159 apps[number - 1] = app 159 apps[number - 1] = app
160 urls[number - 1] = url 160 urls[number - 1] = url
161 i++ 161 i++
162 if (i === total_servers) { 162 if (i === totalServers) {
163 serversRun(apps, urls) 163 serversRun(apps, urls)
164 } 164 }
165 } 165 }
166 166
167 flushTests(function () { 167 flushTests(function () {
168 for (let j = 1; j <= total_servers; j++) { 168 for (let j = 1; j <= totalServers; j++) {
169 // For the virtual buffer 169 // For the virtual buffer
170 setTimeout(function () { 170 setTimeout(function () {
171 runServer(j, function (app, url) { 171 runServer(j, function (app, url) {
@@ -191,7 +191,7 @@ function runServer (number, callback) {
191 } 191 }
192 192
193 // These actions are async so we need to be sure that they have both been done 193 // These actions are async so we need to be sure that they have both been done
194 const server_run_string = { 194 const serverRunString = {
195 'Connected to mongodb': false, 195 'Connected to mongodb': false,
196 'Server listening on port': false 196 'Server listening on port': false
197 } 197 }
@@ -215,7 +215,7 @@ function runServer (number, callback) {
215 215
216 server.app = fork(pathUtils.join(__dirname, '../../../server.js'), [], options) 216 server.app = fork(pathUtils.join(__dirname, '../../../server.js'), [], options)
217 server.app.stdout.on('data', function onStdout (data) { 217 server.app.stdout.on('data', function onStdout (data) {
218 let dont_continue = false 218 let dontContinue = false
219 219
220 // Capture things if we want to 220 // Capture things if we want to
221 for (const key of Object.keys(regexps)) { 221 for (const key of Object.keys(regexps)) {
@@ -230,13 +230,13 @@ function runServer (number, callback) {
230 } 230 }
231 231
232 // Check if all required sentences are here 232 // Check if all required sentences are here
233 for (const key of Object.keys(server_run_string)) { 233 for (const key of Object.keys(serverRunString)) {
234 if (data.toString().indexOf(key) !== -1) server_run_string[key] = true 234 if (data.toString().indexOf(key) !== -1) serverRunString[key] = true
235 if (server_run_string[key] === false) dont_continue = true 235 if (serverRunString[key] === false) dontContinue = true
236 } 236 }
237 237
238 // If no, there is maybe one thing not already initialized (mongodb...) 238 // If no, there is maybe one thing not already initialized (mongodb...)
239 if (dont_continue === true) return 239 if (dontContinue === true) return
240 240
241 server.app.stdout.removeListener('data', onStdout) 241 server.app.stdout.removeListener('data', onStdout)
242 callback(server) 242 callback(server)
@@ -254,14 +254,14 @@ function searchVideo (url, search, end) {
254 .end(end) 254 .end(end)
255} 255}
256 256
257function testImage (url, video_name, image_path, callback) { 257function testImage (url, videoName, imagePath, callback) {
258 request(url) 258 request(url)
259 .get(image_path) 259 .get(imagePath)
260 .expect(200) 260 .expect(200)
261 .end(function (err, res) { 261 .end(function (err, res) {
262 if (err) return callback(err) 262 if (err) return callback(err)
263 263
264 fs.readFile(pathUtils.join(__dirname, 'fixtures', video_name + '.jpg'), function (err, data) { 264 fs.readFile(pathUtils.join(__dirname, 'fixtures', videoName + '.jpg'), function (err, data) {
265 if (err) return callback(err) 265 if (err) return callback(err)
266 266
267 callback(null, data.equals(res.body)) 267 callback(null, data.equals(res.body))
@@ -269,10 +269,10 @@ function testImage (url, video_name, image_path, callback) {
269 }) 269 })
270} 270}
271 271
272function uploadVideo (url, access_token, name, description, fixture, special_status, end) { 272function uploadVideo (url, accessToken, name, description, fixture, specialStatus, end) {
273 if (!end) { 273 if (!end) {
274 end = special_status 274 end = specialStatus
275 special_status = 204 275 specialStatus = 204
276 } 276 }
277 277
278 const path = '/api/v1/videos' 278 const path = '/api/v1/videos'
@@ -280,11 +280,11 @@ function uploadVideo (url, access_token, name, description, fixture, special_sta
280 request(url) 280 request(url)
281 .post(path) 281 .post(path)
282 .set('Accept', 'application/json') 282 .set('Accept', 'application/json')
283 .set('Authorization', 'Bearer ' + access_token) 283 .set('Authorization', 'Bearer ' + accessToken)
284 .field('name', name) 284 .field('name', name)
285 .field('description', description) 285 .field('description', description)
286 .attach('videofile', pathUtils.join(__dirname, 'fixtures', fixture)) 286 .attach('videofile', pathUtils.join(__dirname, 'fixtures', fixture))
287 .expect(special_status) 287 .expect(specialStatus)
288 .end(end) 288 .end(end)
289} 289}
290 290