diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts index 1cb1cf440..f20be8585 100644 --- a/shared/extra-utils/miscs/miscs.ts +++ b/shared/extra-utils/miscs/miscs.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import * as ffmpeg from 'fluent-ffmpeg' | 4 | import * as ffmpeg from 'fluent-ffmpeg' |
5 | import { ensureDir, pathExists, readFile, stat } from 'fs-extra' | 5 | import { ensureDir, exists, pathExists, readFile, stat } from 'fs-extra' |
6 | import { basename, dirname, isAbsolute, join, resolve } from 'path' | 6 | import { basename, dirname, isAbsolute, join, resolve } from 'path' |
7 | import * as request from 'supertest' | 7 | import * as request from 'supertest' |
8 | import * as WebTorrent from 'webtorrent' | 8 | import * as WebTorrent from 'webtorrent' |
@@ -60,8 +60,14 @@ async function testImage (url: string, imageName: string, imagePath: string, ext | |||
60 | const minLength = body.length - ((30 * body.length) / 100) | 60 | const minLength = body.length - ((30 * body.length) / 100) |
61 | const maxLength = body.length + ((30 * body.length) / 100) | 61 | const maxLength = body.length + ((30 * body.length) / 100) |
62 | 62 | ||
63 | expect(data.length).to.be.above(minLength, "the generated image is way smaller than the recorded fixture") | 63 | expect(data.length).to.be.above(minLength, 'the generated image is way smaller than the recorded fixture') |
64 | expect(data.length).to.be.below(maxLength, "the generated image is way larger than the recorded fixture") | 64 | expect(data.length).to.be.below(maxLength, 'the generated image is way larger than the recorded fixture') |
65 | } | ||
66 | |||
67 | async function testFileExistsOrNot (server: { internalServerNumber: number }, directory: string, filePath: string, exist: boolean) { | ||
68 | const base = buildServerDirectory(server, directory) | ||
69 | |||
70 | expect(await pathExists(join(base, filePath))).to.equal(exist) | ||
65 | } | 71 | } |
66 | 72 | ||
67 | function isGithubCI () { | 73 | function isGithubCI () { |
@@ -157,6 +163,7 @@ export { | |||
157 | testImage, | 163 | testImage, |
158 | isGithubCI, | 164 | isGithubCI, |
159 | buildAbsoluteFixturePath, | 165 | buildAbsoluteFixturePath, |
166 | testFileExistsOrNot, | ||
160 | root, | 167 | root, |
161 | generateHighBitrateVideo, | 168 | generateHighBitrateVideo, |
162 | generateVideoWithFramerate | 169 | generateVideoWithFramerate |