aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/checkParams.js30
-rw-r--r--server/tests/api/fixtures/video_too_long.webmbin0 -> 881903 bytes
2 files changed, 23 insertions, 7 deletions
diff --git a/server/tests/api/checkParams.js b/server/tests/api/checkParams.js
index 1f47e5ef4..b63091910 100644
--- a/server/tests/api/checkParams.js
+++ b/server/tests/api/checkParams.js
@@ -11,9 +11,9 @@ const utils = require('./utils')
11describe('Test parameters validator', function () { 11describe('Test parameters validator', function () {
12 let server = null 12 let server = null
13 13
14 function makePostRequest (path, token, fields, attach, done, fail) { 14 function makePostRequest (path, token, fields, attaches, done, fail) {
15 let statusCode = 400 15 let statusCode = 400
16 if (fail !== undefined && fail === false) statusCode = 200 16 if (fail !== undefined && fail === false) statusCode = 204
17 17
18 const req = request(server.url) 18 const req = request(server.url)
19 .post(path) 19 .post(path)
@@ -26,6 +26,11 @@ describe('Test parameters validator', function () {
26 req.field(field, value) 26 req.field(field, value)
27 }) 27 })
28 28
29 Object.keys(attaches).forEach(function (attach) {
30 const value = attaches[attach]
31 req.attach(attach, value)
32 })
33
29 req.expect(statusCode, done) 34 req.expect(statusCode, done)
30 } 35 }
31 36
@@ -200,7 +205,18 @@ describe('Test parameters validator', function () {
200 description: 'my super description' 205 description: 'my super description'
201 } 206 }
202 const attach = { 207 const attach = {
203 'videofile': pathUtils.join(__dirname, '..', 'fixtures', 'video_short_fake.webm') 208 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_short_fake.webm')
209 }
210 makePostRequest(path, server.accessToken, data, attach, done)
211 })
212
213 it('Should fail with a too big duration', function (done) {
214 const data = {
215 name: 'my super name',
216 description: 'my super description'
217 }
218 const attach = {
219 'videofile': pathUtils.join(__dirname, 'fixtures', 'video_too_long.webm')
204 } 220 }
205 makePostRequest(path, server.accessToken, data, attach, done) 221 makePostRequest(path, server.accessToken, data, attach, done)
206 }) 222 })
@@ -217,9 +233,9 @@ describe('Test parameters validator', function () {
217 attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4') 233 attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.mp4')
218 makePostRequest(path, server.accessToken, data, attach, function () { 234 makePostRequest(path, server.accessToken, data, attach, function () {
219 attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv') 235 attach.videofile = pathUtils.join(__dirname, 'fixtures', 'video_short.ogv')
220 makePostRequest(path, server.accessToken, data, attach, done, true) 236 makePostRequest(path, server.accessToken, data, attach, done, false)
221 }, true) 237 }, false)
222 }, true) 238 }, false)
223 }) 239 })
224 }) 240 })
225 241
@@ -234,7 +250,7 @@ describe('Test parameters validator', function () {
234 if (err) throw err 250 if (err) throw err
235 251
236 expect(res.body).to.be.an('array') 252 expect(res.body).to.be.an('array')
237 expect(res.body.length).to.equal(0) 253 expect(res.body.length).to.equal(3)
238 254
239 done() 255 done()
240 }) 256 })
diff --git a/server/tests/api/fixtures/video_too_long.webm b/server/tests/api/fixtures/video_too_long.webm
new file mode 100644
index 000000000..8286f74b0
--- /dev/null
+++ b/server/tests/api/fixtures/video_too_long.webm
Binary files differ