diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-10 17:49:12 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-10 17:49:12 +0200 |
commit | 288178bf02984c7e6dc69241918b88234a0dcb91 (patch) | |
tree | c0258c10aae2c650edd70a3f1588d95fdfd3b390 /server/tests/utils | |
parent | 268eebed921ac13a9ce0f4717f4923aa24190657 (diff) | |
download | PeerTube-288178bf02984c7e6dc69241918b88234a0dcb91.tar.gz PeerTube-288178bf02984c7e6dc69241918b88234a0dcb91.tar.zst PeerTube-288178bf02984c7e6dc69241918b88234a0dcb91.zip |
Try to fix travis tests
Diffstat (limited to 'server/tests/utils')
-rw-r--r-- | server/tests/utils/miscs/miscs.ts | 31 |
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 | ||
39 | async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { | 39 | async 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 | ||
61 | function buildAbsoluteFixturePath (path: string) { | 54 | function buildAbsoluteFixturePath (path: string) { |