diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-10 21:55:59 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-10 21:56:16 +0200 |
commit | 9e5f374090ea0fb16f93edd79d5ad61a55db91e5 (patch) | |
tree | c48f8952d450cc62ed304b0b476d14f42499391f /server/tests/api/utils.js | |
parent | cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07 (diff) | |
download | PeerTube-9e5f374090ea0fb16f93edd79d5ad61a55db91e5.tar.gz PeerTube-9e5f374090ea0fb16f93edd79d5ad61a55db91e5.tar.zst PeerTube-9e5f374090ea0fb16f93edd79d5ad61a55db91e5.zip |
Add tests for thumbnails
Diffstat (limited to 'server/tests/api/utils.js')
-rw-r--r-- | server/tests/api/utils.js | 17 |
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 @@ | |||
3 | const child_process = require('child_process') | 3 | const child_process = require('child_process') |
4 | const exec = child_process.exec | 4 | const exec = child_process.exec |
5 | const fork = child_process.fork | 5 | const fork = child_process.fork |
6 | const fs = require('fs') | ||
6 | const pathUtils = require('path') | 7 | const pathUtils = require('path') |
7 | const request = require('supertest') | 8 | const 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 | ||
257 | function 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 | |||
255 | function uploadVideo (url, access_token, name, description, fixture, special_status, end) { | 272 | function uploadVideo (url, access_token, name, description, fixture, special_status, end) { |
256 | if (!end) { | 273 | if (!end) { |
257 | end = special_status | 274 | end = special_status |