aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/tests/api/fixtures/video_short.mp4.jpgbin0 -> 2618 bytes
-rw-r--r--server/tests/api/fixtures/video_short.ogv.jpgbin0 -> 2618 bytes
-rw-r--r--server/tests/api/fixtures/video_short.webm.jpgbin0 -> 2615 bytes
-rw-r--r--server/tests/api/fixtures/video_short1.webm.jpgbin0 -> 2901 bytes
-rw-r--r--server/tests/api/fixtures/video_short2.webm.jpgbin0 -> 3185 bytes
-rw-r--r--server/tests/api/fixtures/video_short3.webm.jpgbin0 -> 2886 bytes
-rw-r--r--server/tests/api/multiplePods.js26
-rw-r--r--server/tests/api/singlePod.js57
-rw-r--r--server/tests/api/utils.js17
9 files changed, 85 insertions, 15 deletions
diff --git a/server/tests/api/fixtures/video_short.mp4.jpg b/server/tests/api/fixtures/video_short.mp4.jpg
new file mode 100644
index 000000000..48790ffec
--- /dev/null
+++ b/server/tests/api/fixtures/video_short.mp4.jpg
Binary files differ
diff --git a/server/tests/api/fixtures/video_short.ogv.jpg b/server/tests/api/fixtures/video_short.ogv.jpg
new file mode 100644
index 000000000..c4c1d00e5
--- /dev/null
+++ b/server/tests/api/fixtures/video_short.ogv.jpg
Binary files differ
diff --git a/server/tests/api/fixtures/video_short.webm.jpg b/server/tests/api/fixtures/video_short.webm.jpg
new file mode 100644
index 000000000..b0dffd099
--- /dev/null
+++ b/server/tests/api/fixtures/video_short.webm.jpg
Binary files differ
diff --git a/server/tests/api/fixtures/video_short1.webm.jpg b/server/tests/api/fixtures/video_short1.webm.jpg
new file mode 100644
index 000000000..2db21975c
--- /dev/null
+++ b/server/tests/api/fixtures/video_short1.webm.jpg
Binary files differ
diff --git a/server/tests/api/fixtures/video_short2.webm.jpg b/server/tests/api/fixtures/video_short2.webm.jpg
new file mode 100644
index 000000000..ed5952e04
--- /dev/null
+++ b/server/tests/api/fixtures/video_short2.webm.jpg
Binary files differ
diff --git a/server/tests/api/fixtures/video_short3.webm.jpg b/server/tests/api/fixtures/video_short3.webm.jpg
new file mode 100644
index 000000000..b7c41cc1a
--- /dev/null
+++ b/server/tests/api/fixtures/video_short3.webm.jpg
Binary files differ
diff --git a/server/tests/api/multiplePods.js b/server/tests/api/multiplePods.js
index 4a4532a0f..c19f120ef 100644
--- a/server/tests/api/multiplePods.js
+++ b/server/tests/api/multiplePods.js
@@ -110,7 +110,12 @@ describe('Test multiple pods', function () {
110 expect(video.magnetUri).to.equal.magnetUri 110 expect(video.magnetUri).to.equal.magnetUri
111 } 111 }
112 112
113 callback() 113 utils.testImage(server.url, 'video_short1.webm', video.thumbnail_path, function (err, test) {
114 if (err) throw err
115 expect(test).to.equal(true)
116
117 callback()
118 })
114 }) 119 })
115 }, done) 120 }, done)
116 } 121 }
@@ -160,7 +165,12 @@ describe('Test multiple pods', function () {
160 expect(video.magnetUri).to.equal.magnetUri 165 expect(video.magnetUri).to.equal.magnetUri
161 } 166 }
162 167
163 callback() 168 utils.testImage(server.url, 'video_short2.webm', video.thumbnail_path, function (err, test) {
169 if (err) throw err
170 expect(test).to.equal(true)
171
172 callback()
173 })
164 }) 174 })
165 }, done) 175 }, done)
166 } 176 }
@@ -231,7 +241,17 @@ describe('Test multiple pods', function () {
231 expect(video2.magnetUri).to.equal.magnetUri 241 expect(video2.magnetUri).to.equal.magnetUri
232 } 242 }
233 243
234 callback() 244 utils.testImage(server.url, 'video_short3.webm', video1.thumbnail_path, function (err, test) {
245 if (err) throw err
246 expect(test).to.equal(true)
247
248 utils.testImage(server.url, 'video_short.webm', video2.thumbnail_path, function (err, test) {
249 if (err) throw err
250 expect(test).to.equal(true)
251
252 callback()
253 })
254 })
235 }) 255 })
236 }, done) 256 }, done)
237 } 257 }
diff --git a/server/tests/api/singlePod.js b/server/tests/api/singlePod.js
index e2999530e..9a9af0901 100644
--- a/server/tests/api/singlePod.js
+++ b/server/tests/api/singlePod.js
@@ -76,14 +76,19 @@ describe('Test a single pod', function () {
76 expect(video.author).to.equal('root') 76 expect(video.author).to.equal('root')
77 expect(video.isLocal).to.be.true 77 expect(video.isLocal).to.be.true
78 78
79 video_id = video.id 79 utils.testImage(server.url, 'video_short.webm', video.thumbnail_path, function (err, test) {
80 if (err) throw err
81 expect(test).to.equal(true)
80 82
81 webtorrent.add(video.magnetUri, function (torrent) { 83 video_id = video.id
82 expect(torrent.files).to.exist
83 expect(torrent.files.length).to.equal(1)
84 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
85 84
86 done() 85 webtorrent.add(video.magnetUri, function (torrent) {
86 expect(torrent.files).to.exist
87 expect(torrent.files.length).to.equal(1)
88 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
89
90 done()
91 })
87 }) 92 })
88 }) 93 })
89 }) 94 })
@@ -103,12 +108,17 @@ describe('Test a single pod', function () {
103 expect(video.author).to.equal('root') 108 expect(video.author).to.equal('root')
104 expect(video.isLocal).to.be.true 109 expect(video.isLocal).to.be.true
105 110
106 webtorrent.add(video.magnetUri, function (torrent) { 111 utils.testImage(server.url, 'video_short.webm', video.thumbnail_path, function (err, test) {
107 expect(torrent.files).to.exist 112 if (err) throw err
108 expect(torrent.files.length).to.equal(1) 113 expect(test).to.equal(true)
109 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
110 114
111 done() 115 webtorrent.add(video.magnetUri, function (torrent) {
116 expect(torrent.files).to.exist
117 expect(torrent.files.length).to.equal(1)
118 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
119
120 done()
121 })
112 }) 122 })
113 }) 123 })
114 }) 124 })
@@ -127,7 +137,12 @@ describe('Test a single pod', function () {
127 expect(video.author).to.equal('root') 137 expect(video.author).to.equal('root')
128 expect(video.isLocal).to.be.true 138 expect(video.isLocal).to.be.true
129 139
130 done() 140 utils.testImage(server.url, 'video_short.webm', video.thumbnail_path, function (err, test) {
141 if (err) throw err
142 expect(test).to.equal(true)
143
144 done()
145 })
131 }) 146 })
132 }) 147 })
133 148
@@ -197,6 +212,24 @@ describe('Test a single pod', function () {
197 }) 212 })
198 }) 213 })
199 214
215 it('Should have the correct thumbnails', function (done) {
216 utils.getVideosList(server.url, function (err, res) {
217 const videos = res.body
218
219 async.each(videos, function (video, callback_each) {
220 if (err) throw err
221 const video_name = video.name.replace(' name', '')
222
223 utils.testImage(server.url, video_name, video.thumbnail_path, function (err, test) {
224 if (err) throw err
225
226 expect(test).to.equal(true)
227 callback_each()
228 })
229 }, done)
230 })
231 })
232
200 after(function (done) { 233 after(function (done) {
201 process.kill(-server.app.pid) 234 process.kill(-server.app.pid)
202 process.kill(-webtorrent.app.pid) 235 process.kill(-webtorrent.app.pid)
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