aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/utils.js')
-rw-r--r--server/tests/api/utils.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/tests/api/utils.js b/server/tests/api/utils.js
index c1a01ef37..3d3169fde 100644
--- a/server/tests/api/utils.js
+++ b/server/tests/api/utils.js
@@ -3,6 +3,7 @@
3const child_process = require('child_process') 3const child_process = require('child_process')
4const exec = child_process.exec 4const exec = child_process.exec
5const fork = child_process.fork 5const fork = child_process.fork
6const fs = require('fs')
6const pathUtils = require('path') 7const pathUtils = require('path')
7const request = require('supertest') 8const request = require('supertest')
8 9
@@ -19,6 +20,7 @@ const testUtils = {
19 flushAndRunMultipleServers: flushAndRunMultipleServers, 20 flushAndRunMultipleServers: flushAndRunMultipleServers,
20 runServer: runServer, 21 runServer: runServer,
21 searchVideo: searchVideo, 22 searchVideo: searchVideo,
23 testImage: testImage,
22 uploadVideo: uploadVideo 24 uploadVideo: uploadVideo
23} 25}
24 26
@@ -252,6 +254,21 @@ function searchVideo (url, search, end) {
252 .end(end) 254 .end(end)
253} 255}
254 256
257function testImage (url, video_name, image_path, callback) {
258 request(url)
259 .get(image_path)
260 .expect(200)
261 .end(function (err, res) {
262 if (err) return callback(err)
263
264 fs.readFile(pathUtils.join(__dirname, 'fixtures', video_name + '.jpg'), function (err, data) {
265 if (err) return callback(err)
266
267 callback(null, data.equals(res.body))
268 })
269 })
270}
271
255function uploadVideo (url, access_token, name, description, fixture, special_status, end) { 272function uploadVideo (url, access_token, name, description, fixture, special_status, end) {
256 if (!end) { 273 if (!end) {
257 end = special_status 274 end = special_status