diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-18 10:53:54 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-18 15:42:20 +0100 |
commit | f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad (patch) | |
tree | 6d90c0de5dd3ad506e738d447e4f396951ed5624 /server/tests/utils/videos/videos.ts | |
parent | 1174a8479ab9ee47b3305d668fe757435057a298 (diff) | |
download | PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.gz PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.tar.zst PeerTube-f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad.zip |
Don't show videos of remote instance after unfollow
Diffstat (limited to 'server/tests/utils/videos/videos.ts')
-rw-r--r-- | server/tests/utils/videos/videos.ts | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 095d4e29d..270a6042b 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts | |||
@@ -1,13 +1,13 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { readFile } from 'fs' | 4 | import { existsSync, readFile } from 'fs' |
5 | import * as parseTorrent from 'parse-torrent' | 5 | import * as parseTorrent from 'parse-torrent' |
6 | import { extname, isAbsolute, join } from 'path' | 6 | import { extname, isAbsolute, join } from 'path' |
7 | import * as request from 'supertest' | 7 | import * as request from 'supertest' |
8 | import { getMyUserInformation, makeGetRequest, ServerInfo } from '../' | 8 | import { getMyUserInformation, makeGetRequest, root, ServerInfo } from '../' |
9 | import { VideoPrivacy } from '../../../../shared/models/videos' | 9 | import { VideoPrivacy } from '../../../../shared/models/videos' |
10 | import { readFileBufferPromise } from '../../../helpers/core-utils' | 10 | import { readdirPromise, readFileBufferPromise } from '../../../helpers/core-utils' |
11 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers' | 11 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers' |
12 | import { dateIsValid, webtorrentAdd } from '../index' | 12 | import { dateIsValid, webtorrentAdd } from '../index' |
13 | 13 | ||
@@ -203,7 +203,23 @@ function searchVideoWithSort (url: string, search: string, sort: string) { | |||
203 | .expect('Content-Type', /json/) | 203 | .expect('Content-Type', /json/) |
204 | } | 204 | } |
205 | 205 | ||
206 | async function testVideoImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { | 206 | async function checkVideoFilesWereRemoved (videoUUID: string, serverNumber: number) { |
207 | const testDirectory = 'test' + serverNumber | ||
208 | |||
209 | for (const directory of [ 'videos', 'thumbnails', 'torrents', 'previews' ]) { | ||
210 | const directoryPath = join(root(), testDirectory, directory) | ||
211 | |||
212 | const directoryExists = existsSync(directoryPath) | ||
213 | expect(directoryExists).to.be.true | ||
214 | |||
215 | const files = await readdirPromise(directoryPath) | ||
216 | for (const file of files) { | ||
217 | expect(file).to.not.contain(videoUUID) | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | |||
222 | async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { | ||
207 | // Don't test images if the node env is not set | 223 | // Don't test images if the node env is not set |
208 | // Because we need a special ffmpeg version for this test | 224 | // Because we need a special ffmpeg version for this test |
209 | if (process.env['NODE_TEST_IMAGE']) { | 225 | if (process.env['NODE_TEST_IMAGE']) { |
@@ -409,7 +425,7 @@ async function completeVideoCheck ( | |||
409 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) | 425 | const maxSize = attributeFile.size + ((10 * attributeFile.size) / 100) |
410 | expect(file.size).to.be.above(minSize).and.below(maxSize) | 426 | expect(file.size).to.be.above(minSize).and.below(maxSize) |
411 | 427 | ||
412 | const test = await testVideoImage(url, attributes.fixture, videoDetails.thumbnailPath) | 428 | const test = await testImage(url, attributes.fixture, videoDetails.thumbnailPath) |
413 | expect(test).to.equal(true) | 429 | expect(test).to.equal(true) |
414 | 430 | ||
415 | const torrent = await webtorrentAdd(magnetUri, true) | 431 | const torrent = await webtorrentAdd(magnetUri, true) |
@@ -437,11 +453,12 @@ export { | |||
437 | searchVideo, | 453 | searchVideo, |
438 | searchVideoWithPagination, | 454 | searchVideoWithPagination, |
439 | searchVideoWithSort, | 455 | searchVideoWithSort, |
440 | testVideoImage, | 456 | testImage, |
441 | uploadVideo, | 457 | uploadVideo, |
442 | updateVideo, | 458 | updateVideo, |
443 | rateVideo, | 459 | rateVideo, |
444 | viewVideo, | 460 | viewVideo, |
445 | parseTorrentVideo, | 461 | parseTorrentVideo, |
446 | completeVideoCheck | 462 | completeVideoCheck, |
463 | checkVideoFilesWereRemoved | ||
447 | } | 464 | } |