ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix tests
Chocobozzz9ee83eb99e90
diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.tsindex e6666619bf..f93e2372e7 100644--- a/server/tests/utils/miscs/miscs.ts+++ b/server/tests/utils/miscs/miscs.ts@@ -1,5 +1,10 @@+/* tslint:disable:no-unused-expression */++import { expect } from 'chai'import { join } from 'path'+import * as request from 'supertest'import * as WebTorrent from 'webtorrent'+import { readFileBufferPromise } from '../../../helpers/core-utils'let webtorrent = new WebTorrent()@@ -30,6 +35,27 @@ function root () {return join(__dirname, '..', '..', '..', '..')}+async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {+ // Don't test images if the node env is not set+ // Because we need a special ffmpeg version for this test+ if (process.env[ 'NODE_TEST_IMAGE' ]) {+ const res = await request(url)+ .get(imagePath)+ .expect(200)++ const body = res.body++ const data = await readFileBufferPromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension))+ const minLength = body.length - ((50 * body.length) / 100)+ const maxLength = body.length + ((50 * body.length) / 100)++ return data.length > minLength && data.length < maxLength+ } else {+ console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.')+ return true+ }+}+// ---------------------------------------------------------------------------export {@@ -37,5 +63,6 @@ export {wait,webtorrentAdd,immutableAssign,+ testImage,root}diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.tsindex 270a6042be..605acf5657 100644--- a/server/tests/utils/videos/videos.ts+++ b/server/tests/utils/videos/videos.ts@@ -5,7 +5,7 @@ import { existsSync, readFile } from 'fs'import * as parseTorrent from 'parse-torrent'import { extname, isAbsolute, join } from 'path'import * as request from 'supertest'-import { getMyUserInformation, makeGetRequest, root, ServerInfo } from '../'+import { getMyUserInformation, makeGetRequest, root, ServerInfo, testImage } from '../'import { VideoPrivacy } from '../../../../shared/models/videos'import { readdirPromise, readFileBufferPromise } from '../../../helpers/core-utils'import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers'@@ -219,23 +219,6 @@ async function checkVideoFilesWereRemoved (videoUUID: string, serverNumber: numb}}-async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {- // Don't test images if the node env is not set- // Because we need a special ffmpeg version for this test- if (process.env['NODE_TEST_IMAGE']) {- const res = await request(url)- .get(imagePath)- .expect(200)-- const data = await readFileBufferPromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension))-- return data.equals(res.body)- } else {- console.log('Do not test images. Enable it by setting NODE_TEST_IMAGE env variable.')- return true- }-}-async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 200) {const path = '/api/v1/videos/upload'let defaultChannelId = '1'@@ -453,7 +436,6 @@ export {searchVideo,searchVideoWithPagination,searchVideoWithSort,- testImage,uploadVideo,updateVideo,rateVideo,diff --git a/openapi.yaml b/support/doc/api/openapi.yamlsimilarity index 100%rename from openapi.yamlrename to support/doc/api/openapi.yaml