aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-07-30 09:43:12 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-07-31 11:32:04 +0200
commitb488ba1e26b803ac6c637e8b11bdd444ca4c803f (patch)
tree0a9ce01fcfb26ecddd8a0dccf997514818b8a72f /shared
parentb9fe9a7ffdf80d81c5580ccccfeb989051fd9d8a (diff)
downloadPeerTube-b488ba1e26b803ac6c637e8b11bdd444ca4c803f.tar.gz
PeerTube-b488ba1e26b803ac6c637e8b11bdd444ca4c803f.tar.zst
PeerTube-b488ba1e26b803ac6c637e8b11bdd444ca4c803f.zip
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
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/miscs/miscs.ts15
-rw-r--r--shared/extra-utils/videos/video-imports.ts7
2 files changed, 17 insertions, 5 deletions
diff --git a/shared/extra-utils/miscs/miscs.ts b/shared/extra-utils/miscs/miscs.ts
index 2239d5bcc..caf09c01f 100644
--- a/shared/extra-utils/miscs/miscs.ts
+++ b/shared/extra-utils/miscs/miscs.ts
@@ -64,19 +64,25 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
64} 64}
65 65
66function buildAbsoluteFixturePath (path: string, customCIPath = false) { 66function buildAbsoluteFixturePath (path: string, customCIPath = false) {
67 if (isAbsolute(path)) { 67 if (isAbsolute(path)) return path
68 return path
69 }
70 68
71 if (customCIPath) { 69 if (customCIPath) {
72 if (process.env.GITLAB_CI) return join(root(), 'cached-fixtures', path) 70 if (process.env.GITLAB_CI) return join(root(), 'cached-fixtures', path)
73 71
74 if (process.env.TRAVIS) return join(process.env.HOME, 'fixtures', path) 72 return join(process.env.HOME, 'fixtures', path)
75 } 73 }
76 74
77 return join(root(), 'server', 'tests', 'fixtures', path) 75 return join(root(), 'server', 'tests', 'fixtures', path)
78} 76}
79 77
78function areHttpImportTestsDisabled () {
79 const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
80
81 if (disabled) console.log('Import tests are disabled')
82
83 return disabled
84}
85
80async function generateHighBitrateVideo () { 86async function generateHighBitrateVideo () {
81 const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true) 87 const tempFixturePath = buildAbsoluteFixturePath('video_high_bitrate_1080p.mp4', true)
82 88
@@ -131,6 +137,7 @@ async function generateVideoWithFramerate (fps = 60) {
131export { 137export {
132 dateIsValid, 138 dateIsValid,
133 wait, 139 wait,
140 areHttpImportTestsDisabled,
134 buildServerDirectory, 141 buildServerDirectory,
135 webtorrentAdd, 142 webtorrentAdd,
136 immutableAssign, 143 immutableAssign,
diff --git a/shared/extra-utils/videos/video-imports.ts b/shared/extra-utils/videos/video-imports.ts
index d235181b0..6249e8a94 100644
--- a/shared/extra-utils/videos/video-imports.ts
+++ b/shared/extra-utils/videos/video-imports.ts
@@ -15,6 +15,10 @@ function getBadVideoUrl () {
15 return 'https://download.cpy.re/peertube/bad_video.mp4' 15 return 'https://download.cpy.re/peertube/bad_video.mp4'
16} 16}
17 17
18function getGoodVideoUrl () {
19 return 'https://download.cpy.re/peertube/good_video.mp4'
20}
21
18function importVideo (url: string, token: string, attributes: VideoImportCreate & { torrentfile?: string }, statusCodeExpected = 200) { 22function importVideo (url: string, token: string, attributes: VideoImportCreate & { torrentfile?: string }, statusCodeExpected = 200) {
19 const path = '/api/v1/videos/imports' 23 const path = '/api/v1/videos/imports'
20 24
@@ -53,5 +57,6 @@ export {
53 getYoutubeVideoUrl, 57 getYoutubeVideoUrl,
54 importVideo, 58 importVideo,
55 getMagnetURI, 59 getMagnetURI,
56 getMyVideoImports 60 getMyVideoImports,
61 getGoodVideoUrl
57} 62}