diff options
author | Chocobozzz <me@florianbigard.com> | 2020-07-30 09:43:12 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-07-31 11:32:04 +0200 |
commit | b488ba1e26b803ac6c637e8b11bdd444ca4c803f (patch) | |
tree | 0a9ce01fcfb26ecddd8a0dccf997514818b8a72f | |
parent | b9fe9a7ffdf80d81c5580ccccfeb989051fd9d8a (diff) | |
download | PeerTube-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
-rw-r--r-- | .github/workflows/test.yml | 10 | ||||
-rwxr-xr-x | scripts/ci.sh | 2 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 13 | ||||
-rw-r--r-- | server/tests/api/check-params/video-imports.ts | 24 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 10 | ||||
-rw-r--r-- | server/tests/api/videos/video-blacklist.ts | 10 | ||||
-rw-r--r-- | server/tests/api/videos/video-imports.ts | 14 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 8 | ||||
-rw-r--r-- | shared/extra-utils/miscs/miscs.ts | 15 | ||||
-rw-r--r-- | shared/extra-utils/videos/video-imports.ts | 7 |
10 files changed, 64 insertions, 49 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index feb885378..a2f93ce3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml | |||
@@ -22,13 +22,15 @@ jobs: | |||
22 | POSTGRES_HOST_AUTH_METHOD: trust | 22 | POSTGRES_HOST_AUTH_METHOD: trust |
23 | 23 | ||
24 | strategy: | 24 | strategy: |
25 | fail-fast: true | 25 | fail-fast: false |
26 | matrix: | 26 | matrix: |
27 | test_suite: [ misc, api-1, api-2, api-3, api-4, cli, lint ] | 27 | test_suite: [ misc, api-1, api-2, api-3, api-4, cli, lint ] |
28 | 28 | ||
29 | env: | 29 | env: |
30 | PGUSER: peertube | 30 | PGUSER: peertube |
31 | PGHOST: localhost | 31 | PGHOST: localhost |
32 | DISABLE_HTTP_IMPORT_TESTS: true | ||
33 | NODE_PENDING_JOB_WAIT: 2000 | ||
32 | 34 | ||
33 | steps: | 35 | steps: |
34 | - uses: actions/checkout@v2 | 36 | - uses: actions/checkout@v2 |
@@ -50,7 +52,9 @@ jobs: | |||
50 | - name: Cache Node.js modules | 52 | - name: Cache Node.js modules |
51 | uses: actions/cache@v2 | 53 | uses: actions/cache@v2 |
52 | with: | 54 | with: |
53 | path: ~/.cache/yarn | 55 | path: | |
56 | **/node_modules | ||
57 | ~/fixtures | ||
54 | key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} | 58 | key: ${{ runner.OS }}-node-${{ hashFiles('**/yarn.lock') }} |
55 | restore-keys: | | 59 | restore-keys: | |
56 | ${{ runner.OS }}-node- | 60 | ${{ runner.OS }}-node- |
@@ -69,5 +73,5 @@ jobs: | |||
69 | uses: actions/upload-artifact@v2 | 73 | uses: actions/upload-artifact@v2 |
70 | if: failure() | 74 | if: failure() |
71 | with: | 75 | with: |
72 | name: test-storages | 76 | name: test-storages-${{ matrix.test_suite }} |
73 | path: test*/logs | 77 | path: test*/logs |
diff --git a/scripts/ci.sh b/scripts/ci.sh index f5bd0bdc9..cef276da3 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh | |||
@@ -21,7 +21,7 @@ if [ "$1" = "misc" ]; then | |||
21 | server/tests/plugins/index.ts | 21 | server/tests/plugins/index.ts |
22 | elif [ "$1" = "cli" ]; then | 22 | elif [ "$1" = "cli" ]; then |
23 | npm run build:server | 23 | npm run build:server |
24 | CC=gcc-4.9 CXX=g++-4.9 npm run setup:cli | 24 | npm run setup:cli |
25 | mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail server/tests/cli/index.ts | 25 | mocha --timeout 5000 --exit --require ts-node/register --require tsconfig-paths/register --bail server/tests/cli/index.ts |
26 | elif [ "$1" = "api-1" ]; then | 26 | elif [ "$1" = "api-1" ]; then |
27 | npm run build:server | 27 | npm run build:server |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 2fea2cbd5..3e53c445d 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { omit } from 'lodash' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | ||
5 | import { omit } from 'lodash' | ||
5 | import { join } from 'path' | 6 | import { join } from 'path' |
6 | import { User, UserRole, VideoImport, VideoImportState } from '../../../../shared' | 7 | import { User, UserRole, VideoImport, VideoImportState } from '../../../../shared' |
7 | |||
8 | import { | 8 | import { |
9 | addVideoChannel, | 9 | addVideoChannel, |
10 | blockUser, | 10 | blockUser, |
@@ -31,17 +31,16 @@ import { | |||
31 | uploadVideo, | 31 | uploadVideo, |
32 | userLogin | 32 | userLogin |
33 | } from '../../../../shared/extra-utils' | 33 | } from '../../../../shared/extra-utils' |
34 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' | ||
34 | import { | 35 | import { |
35 | checkBadCountPagination, | 36 | checkBadCountPagination, |
36 | checkBadSortPagination, | 37 | checkBadSortPagination, |
37 | checkBadStartPagination | 38 | checkBadStartPagination |
38 | } from '../../../../shared/extra-utils/requests/check-api-params' | 39 | } from '../../../../shared/extra-utils/requests/check-api-params' |
39 | import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | ||
40 | import { VideoPrivacy } from '../../../../shared/models/videos' | ||
41 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 40 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
42 | import { expect } from 'chai' | 41 | import { getMagnetURI, getMyVideoImports, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
43 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' | 42 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' |
44 | import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' | 43 | import { VideoPrivacy } from '../../../../shared/models/videos' |
45 | 44 | ||
46 | describe('Test users API validators', function () { | 45 | describe('Test users API validators', function () { |
47 | const path = '/api/v1/users/' | 46 | const path = '/api/v1/users/' |
@@ -1047,7 +1046,7 @@ describe('Test users API validators', function () { | |||
1047 | channelId: 1, | 1046 | channelId: 1, |
1048 | privacy: VideoPrivacy.PUBLIC | 1047 | privacy: VideoPrivacy.PUBLIC |
1049 | } | 1048 | } |
1050 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getYoutubeVideoUrl() })) | 1049 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { targetUrl: getGoodVideoUrl() })) |
1051 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() })) | 1050 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { magnetUri: getMagnetURI() })) |
1052 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any })) | 1051 | await importVideo(server.url, server.accessToken, immutableAssign(baseAttributes, { torrentfile: 'video-720p.torrent' as any })) |
1053 | 1052 | ||
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 3759e47c4..f954ba089 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -1,9 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { omit } from 'lodash' | ||
4 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | ||
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
7 | import { | 6 | import { |
8 | cleanupTests, | 7 | cleanupTests, |
9 | createUser, | 8 | createUser, |
@@ -23,7 +22,8 @@ import { | |||
23 | checkBadSortPagination, | 22 | checkBadSortPagination, |
24 | checkBadStartPagination | 23 | checkBadStartPagination |
25 | } from '../../../../shared/extra-utils/requests/check-api-params' | 24 | } from '../../../../shared/extra-utils/requests/check-api-params' |
26 | import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' | 25 | import { getMagnetURI, getGoodVideoUrl } from '../../../../shared/extra-utils/videos/video-imports' |
26 | import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum' | ||
27 | 27 | ||
28 | describe('Test video imports API validator', function () { | 28 | describe('Test video imports API validator', function () { |
29 | const path = '/api/v1/videos/imports' | 29 | const path = '/api/v1/videos/imports' |
@@ -76,7 +76,7 @@ describe('Test video imports API validator', function () { | |||
76 | 76 | ||
77 | before(function () { | 77 | before(function () { |
78 | baseCorrectParams = { | 78 | baseCorrectParams = { |
79 | targetUrl: getYoutubeVideoUrl(), | 79 | targetUrl: getGoodVideoUrl(), |
80 | name: 'my super name', | 80 | name: 'my super name', |
81 | category: 5, | 81 | category: 5, |
82 | licence: 1, | 82 | licence: 1, |
@@ -246,15 +246,13 @@ describe('Test video imports API validator', function () { | |||
246 | it('Should succeed with the correct parameters', async function () { | 246 | it('Should succeed with the correct parameters', async function () { |
247 | this.timeout(30000) | 247 | this.timeout(30000) |
248 | 248 | ||
249 | { | 249 | await makePostBodyRequest({ |
250 | await makePostBodyRequest({ | 250 | url: server.url, |
251 | url: server.url, | 251 | path, |
252 | path, | 252 | token: server.accessToken, |
253 | token: server.accessToken, | 253 | fields: baseCorrectParams, |
254 | fields: baseCorrectParams, | 254 | statusCodeExpected: 200 |
255 | statusCodeExpected: 200 | 255 | }) |
256 | }) | ||
257 | } | ||
258 | }) | 256 | }) |
259 | 257 | ||
260 | it('Should forbid to import http videos', async function () { | 258 | it('Should forbid to import http videos', async function () { |
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index e5f6aa864..af4ff42b0 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -24,7 +24,7 @@ import { | |||
24 | prepareNotificationsTest | 24 | prepareNotificationsTest |
25 | } from '../../../../shared/extra-utils/users/user-notifications' | 25 | } from '../../../../shared/extra-utils/users/user-notifications' |
26 | import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' | 26 | import { addUserSubscription, removeUserSubscription } from '../../../../shared/extra-utils/users/user-subscriptions' |
27 | import { getBadVideoUrl, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 27 | import { getBadVideoUrl, getGoodVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
28 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' | 28 | import { UserNotification, UserNotificationType } from '../../../../shared/models/users' |
29 | import { VideoPrivacy } from '../../../../shared/models/videos' | 29 | import { VideoPrivacy } from '../../../../shared/models/videos' |
30 | 30 | ||
@@ -213,7 +213,7 @@ describe('Test user notifications', function () { | |||
213 | name, | 213 | name, |
214 | channelId, | 214 | channelId, |
215 | privacy: VideoPrivacy.PUBLIC, | 215 | privacy: VideoPrivacy.PUBLIC, |
216 | targetUrl: getYoutubeVideoUrl() | 216 | targetUrl: getGoodVideoUrl() |
217 | } | 217 | } |
218 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 218 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) |
219 | const uuid = res.body.video.uuid | 219 | const uuid = res.body.video.uuid |
@@ -284,7 +284,7 @@ describe('Test user notifications', function () { | |||
284 | name, | 284 | name, |
285 | channelId, | 285 | channelId, |
286 | privacy: VideoPrivacy.PUBLIC, | 286 | privacy: VideoPrivacy.PUBLIC, |
287 | targetUrl: getYoutubeVideoUrl(), | 287 | targetUrl: getGoodVideoUrl(), |
288 | waitTranscoding: true | 288 | waitTranscoding: true |
289 | } | 289 | } |
290 | const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) | 290 | const res = await importVideo(servers[1].url, servers[1].accessToken, attributes) |
@@ -371,13 +371,13 @@ describe('Test user notifications', function () { | |||
371 | name, | 371 | name, |
372 | channelId, | 372 | channelId, |
373 | privacy: VideoPrivacy.PRIVATE, | 373 | privacy: VideoPrivacy.PRIVATE, |
374 | targetUrl: getYoutubeVideoUrl() | 374 | targetUrl: getGoodVideoUrl() |
375 | } | 375 | } |
376 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 376 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) |
377 | const uuid = res.body.video.uuid | 377 | const uuid = res.body.video.uuid |
378 | 378 | ||
379 | await waitJobs(servers) | 379 | await waitJobs(servers) |
380 | await checkMyVideoImportIsFinished(baseParams, name, uuid, getYoutubeVideoUrl(), true, 'presence') | 380 | await checkMyVideoImportIsFinished(baseParams, name, uuid, getGoodVideoUrl(), true, 'presence') |
381 | }) | 381 | }) |
382 | }) | 382 | }) |
383 | 383 | ||
diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index a8500627b..52cac20d9 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | ||
3 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
4 | import { orderBy } from 'lodash' | 5 | import { orderBy } from 'lodash' |
5 | import 'mocha' | ||
6 | import { | 6 | import { |
7 | addVideoToBlacklist, | 7 | addVideoToBlacklist, |
8 | cleanupTests, | 8 | cleanupTests, |
@@ -25,10 +25,10 @@ import { | |||
25 | } from '../../../../shared/extra-utils/index' | 25 | } from '../../../../shared/extra-utils/index' |
26 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' | 26 | import { doubleFollow } from '../../../../shared/extra-utils/server/follows' |
27 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 27 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
28 | import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' | 28 | import { getGoodVideoUrl, getMagnetURI, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
29 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' | ||
30 | import { User, UserRole } from '../../../../shared/models/users' | 29 | import { User, UserRole } from '../../../../shared/models/users' |
31 | import { getMagnetURI, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 30 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' |
31 | import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' | ||
32 | 32 | ||
33 | const expect = chai.expect | 33 | const expect = chai.expect |
34 | 34 | ||
@@ -424,7 +424,7 @@ describe('Test video blacklist', function () { | |||
424 | this.timeout(15000) | 424 | this.timeout(15000) |
425 | 425 | ||
426 | const attributes = { | 426 | const attributes = { |
427 | targetUrl: getYoutubeVideoUrl(), | 427 | targetUrl: getGoodVideoUrl(), |
428 | name: 'URL import', | 428 | name: 'URL import', |
429 | channelId: channelOfUserWithoutFlag | 429 | channelId: channelOfUserWithoutFlag |
430 | } | 430 | } |
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index 05ee36b27..efda4fc7b 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import * as chai from 'chai' | ||
4 | import 'mocha' | 3 | import 'mocha' |
5 | import { VideoDetails, VideoImport, VideoPrivacy, VideoCaption } from '../../../../shared/models/videos' | 4 | import * as chai from 'chai' |
6 | import { | 5 | import { |
7 | cleanupTests, | 6 | cleanupTests, |
8 | doubleFollow, | 7 | doubleFollow, |
@@ -11,15 +10,16 @@ import { | |||
11 | getMyVideos, | 10 | getMyVideos, |
12 | getVideo, | 11 | getVideo, |
13 | getVideosList, | 12 | getVideosList, |
14 | listVideoCaptions, | ||
15 | testCaptionFile, | ||
16 | immutableAssign, | 13 | immutableAssign, |
14 | listVideoCaptions, | ||
17 | ServerInfo, | 15 | ServerInfo, |
18 | setAccessTokensToServers | 16 | setAccessTokensToServers, |
17 | testCaptionFile | ||
19 | } from '../../../../shared/extra-utils' | 18 | } from '../../../../shared/extra-utils' |
19 | import { areHttpImportTestsDisabled, testImage } from '../../../../shared/extra-utils/miscs/miscs' | ||
20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
21 | import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' | 21 | import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/extra-utils/videos/video-imports' |
22 | import { testImage } from '../../../../shared/extra-utils/miscs/miscs' | 22 | import { VideoCaption, VideoDetails, VideoImport, VideoPrivacy } from '../../../../shared/models/videos' |
23 | 23 | ||
24 | const expect = chai.expect | 24 | const expect = chai.expect |
25 | 25 | ||
@@ -28,6 +28,8 @@ describe('Test video imports', function () { | |||
28 | let channelIdServer1: number | 28 | let channelIdServer1: number |
29 | let channelIdServer2: number | 29 | let channelIdServer2: number |
30 | 30 | ||
31 | if (areHttpImportTestsDisabled()) return | ||
32 | |||
31 | async function checkVideosServer1 (url: string, idHttp: string, idMagnet: string, idTorrent: string) { | 33 | async function checkVideosServer1 (url: string, idHttp: string, idMagnet: string, idTorrent: string) { |
32 | const resHttp = await getVideo(url, idHttp) | 34 | const resHttp = await getVideo(url, idHttp) |
33 | const videoHttp: VideoDetails = resHttp.body | 35 | const videoHttp: VideoDetails = resHttp.body |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 41242318e..4d354b68e 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -24,7 +24,7 @@ import { | |||
24 | waitJobs | 24 | waitJobs |
25 | } from '../../../shared/extra-utils' | 25 | } from '../../../shared/extra-utils' |
26 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' | 26 | import { cleanupTests, flushAndRunMultipleServers, ServerInfo } from '../../../shared/extra-utils/server/servers' |
27 | import { getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../shared/extra-utils/videos/video-imports' | 27 | import { getGoodVideoUrl, getMyVideoImports, importVideo } from '../../../shared/extra-utils/videos/video-imports' |
28 | import { VideoDetails, VideoImport, VideoImportState, VideoPrivacy } from '../../../shared/models/videos' | 28 | import { VideoDetails, VideoImport, VideoImportState, VideoPrivacy } from '../../../shared/models/videos' |
29 | import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' | 29 | import { VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model' |
30 | 30 | ||
@@ -92,7 +92,7 @@ describe('Test plugin filter hooks', function () { | |||
92 | name: 'normal title', | 92 | name: 'normal title', |
93 | privacy: VideoPrivacy.PUBLIC, | 93 | privacy: VideoPrivacy.PUBLIC, |
94 | channelId: servers[0].videoChannel.id, | 94 | channelId: servers[0].videoChannel.id, |
95 | targetUrl: getYoutubeVideoUrl() + 'bad' | 95 | targetUrl: getGoodVideoUrl() + 'bad' |
96 | } | 96 | } |
97 | await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403) | 97 | await importVideo(servers[0].url, servers[0].accessToken, baseAttributes, 403) |
98 | }) | 98 | }) |
@@ -117,7 +117,7 @@ describe('Test plugin filter hooks', function () { | |||
117 | name: 'title with bad word', | 117 | name: 'title with bad word', |
118 | privacy: VideoPrivacy.PUBLIC, | 118 | privacy: VideoPrivacy.PUBLIC, |
119 | channelId: servers[0].videoChannel.id, | 119 | channelId: servers[0].videoChannel.id, |
120 | targetUrl: getYoutubeVideoUrl() | 120 | targetUrl: getGoodVideoUrl() |
121 | } | 121 | } |
122 | const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes) | 122 | const res = await importVideo(servers[0].url, servers[0].accessToken, baseAttributes) |
123 | videoImportId = res.body.id | 123 | videoImportId = res.body.id |
@@ -220,7 +220,7 @@ describe('Test plugin filter hooks', function () { | |||
220 | 220 | ||
221 | const attributes = { | 221 | const attributes = { |
222 | name: 'video please blacklist me', | 222 | name: 'video please blacklist me', |
223 | targetUrl: getYoutubeVideoUrl(), | 223 | targetUrl: getGoodVideoUrl(), |
224 | channelId: servers[0].videoChannel.id | 224 | channelId: servers[0].videoChannel.id |
225 | } | 225 | } |
226 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) | 226 | const res = await importVideo(servers[0].url, servers[0].accessToken, attributes) |
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 | ||
66 | function buildAbsoluteFixturePath (path: string, customCIPath = false) { | 66 | function 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 | ||
78 | function 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 | |||
80 | async function generateHighBitrateVideo () { | 86 | async 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) { | |||
131 | export { | 137 | export { |
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 | ||
18 | function getGoodVideoUrl () { | ||
19 | return 'https://download.cpy.re/peertube/good_video.mp4' | ||
20 | } | ||
21 | |||
18 | function importVideo (url: string, token: string, attributes: VideoImportCreate & { torrentfile?: string }, statusCodeExpected = 200) { | 22 | function 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 | } |