Don't rely on youtube for tests

Use another import URL when possible, and disable import tests when we
want to do a youtube import test
This commit is contained in:
Chocobozzz 2020-07-30 09:43:12 +02:00 committed by Chocobozzz
parent b9fe9a7ffd
commit b488ba1e26
10 changed files with 64 additions and 49 deletions

View file

@ -64,19 +64,25 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
}
function buildAbsoluteFixturePath (path: string, customCIPath = false) {
if (isAbsolute(path)) {
return path
}
if (isAbsolute(path)) return path
if (customCIPath) {
if (process.env.GITLAB_CI) return join(root(), 'cached-fixtures', path)
if (process.env.TRAVIS) return join(process.env.HOME, 'fixtures', path)
return join(process.env.HOME, 'fixtures', path)
}
return join(root(), 'server', 'tests', 'fixtures', path)
}
function areHttpImportTestsDisabled () {
const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
if (disabled) console.log('Import tests are disabled')
return disabled
}
async function generateHighBitrateVideo () {
const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true)
@ -131,6 +137,7 @@ async function generateVideoWithFramerate (fps = 60) {
export {
dateIsValid,
wait,
areHttpImportTestsDisabled,
buildServerDirectory,
webtorrentAdd,
immutableAssign,

View file

@ -15,6 +15,10 @@ function getBadVideoUrl () {
return 'https://download.cpy.re/peertube/bad_video.mp4'
}
function getGoodVideoUrl () {
return 'https://download.cpy.re/peertube/good_video.mp4'
}
function importVideo (url: string, token: string, attributes: VideoImportCreate & { torrentfile?: string }, statusCodeExpected = 200) {
const path = '/api/v1/videos/imports'
@ -53,5 +57,6 @@ export {
getYoutubeVideoUrl,
importVideo,
getMagnetURI,
getMyVideoImports
getMyVideoImports,
getGoodVideoUrl
}