aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/utils/miscs
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-10 17:49:12 +0200
committerChocobozzz <me@florianbigard.com>2018-08-10 17:49:12 +0200
commit288178bf02984c7e6dc69241918b88234a0dcb91 (patch)
treec0258c10aae2c650edd70a3f1588d95fdfd3b390 /server/tests/utils/miscs
parent268eebed921ac13a9ce0f4717f4923aa24190657 (diff)
downloadPeerTube-288178bf02984c7e6dc69241918b88234a0dcb91.tar.gz
PeerTube-288178bf02984c7e6dc69241918b88234a0dcb91.tar.zst
PeerTube-288178bf02984c7e6dc69241918b88234a0dcb91.zip
Try to fix travis tests
Diffstat (limited to 'server/tests/utils/miscs')
-rw-r--r--server/tests/utils/miscs/miscs.ts31
1 files changed, 12 insertions, 19 deletions
diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts
index 5e46004a7..b0667491b 100644
--- a/server/tests/utils/miscs/miscs.ts
+++ b/server/tests/utils/miscs/miscs.ts
@@ -37,25 +37,18 @@ function root () {
37} 37}
38 38
39async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { 39async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
40 // Don't test images if the node env is not set 40 const res = await request(url)
41 // Because we need a special ffmpeg version for this test 41 .get(imagePath)
42 if (process.env[ 'NODE_TEST_IMAGE' ]) { 42 .expect(200)
43 const res = await request(url) 43
44 .get(imagePath) 44 const body = res.body
45 .expect(200) 45
46 46 const data = await readFileBufferPromise(join(__dirname, '..', '..', 'fixtures', imageName + extension))
47 const body = res.body 47 const minLength = body.length - ((20 * body.length) / 100)
48 48 const maxLength = body.length + ((20 * body.length) / 100)
49 const data = await readFileBufferPromise(join(__dirname, '..', '..', 'fixtures', imageName + extension)) 49
50 const minLength = body.length - ((20 * body.length) / 100) 50 expect(data.length).to.be.above(minLength)
51 const maxLength = body.length + ((20 * body.length) / 100) 51 expect(data.length).to.be.below(maxLength)
52
53 expect(data.length).to.be.above(minLength)
54 expect(data.length).to.be.below(maxLength)
55 } else {
56 console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.')
57 return true
58 }
59} 52}
60 53
61function buildAbsoluteFixturePath (path: string) { 54function buildAbsoluteFixturePath (path: string) {