aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/miscs
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/miscs')
-rw-r--r--shared/extra-utils/miscs/checks.ts7
-rw-r--r--shared/extra-utils/miscs/tests.ts15
2 files changed, 19 insertions, 3 deletions
diff --git a/shared/extra-utils/miscs/checks.ts b/shared/extra-utils/miscs/checks.ts
index 7fc92f804..aa2c8e8fa 100644
--- a/shared/extra-utils/miscs/checks.ts
+++ b/shared/extra-utils/miscs/checks.ts
@@ -16,6 +16,10 @@ function dateIsValid (dateString: string, interval = 300000) {
16 return Math.abs(now.getTime() - dateToCheck.getTime()) <= interval 16 return Math.abs(now.getTime() - dateToCheck.getTime()) <= interval
17} 17}
18 18
19function expectStartWith (str: string, start: string) {
20 expect(str.startsWith(start), `${str} does not start with ${start}`).to.be.true
21}
22
19async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { 23async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') {
20 const res = await makeGetRequest({ 24 const res = await makeGetRequest({
21 url, 25 url,
@@ -42,5 +46,6 @@ async function testFileExistsOrNot (server: PeerTubeServer, directory: string, f
42export { 46export {
43 dateIsValid, 47 dateIsValid,
44 testImage, 48 testImage,
45 testFileExistsOrNot 49 testFileExistsOrNot,
50 expectStartWith
46} 51}
diff --git a/shared/extra-utils/miscs/tests.ts b/shared/extra-utils/miscs/tests.ts
index 3dfb2487e..dd86041fe 100644
--- a/shared/extra-utils/miscs/tests.ts
+++ b/shared/extra-utils/miscs/tests.ts
@@ -28,7 +28,9 @@ const FIXTURE_URLS = {
28 28
29 badVideo: 'https://download.cpy.re/peertube/bad_video.mp4', 29 badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',
30 goodVideo: 'https://download.cpy.re/peertube/good_video.mp4', 30 goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',
31 video4K: 'https://download.cpy.re/peertube/4k_file.txt' 31 goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4',
32
33 file4K: 'https://download.cpy.re/peertube/4k_file.txt'
32} 34}
33 35
34function parallelTests () { 36function parallelTests () {
@@ -42,7 +44,15 @@ function isGithubCI () {
42function areHttpImportTestsDisabled () { 44function areHttpImportTestsDisabled () {
43 const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true' 45 const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
44 46
45 if (disabled) console.log('Import tests are disabled') 47 if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled')
48
49 return disabled
50}
51
52function areObjectStorageTestsDisabled () {
53 const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'
54
55 if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled')
46 56
47 return disabled 57 return disabled
48} 58}
@@ -89,6 +99,7 @@ export {
89 buildAbsoluteFixturePath, 99 buildAbsoluteFixturePath,
90 getFileSize, 100 getFileSize,
91 buildRequestStub, 101 buildRequestStub,
102 areObjectStorageTestsDisabled,
92 wait, 103 wait,
93 root 104 root
94} 105}