From 99d103019c76c517ba607a0fab8022aa6d08ef2e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 7 Jun 2018 09:48:10 +0200 Subject: [PATCH] Move fixtures in tests/ --- server/tests/api/check-params/users.ts | 6 ++-- server/tests/api/check-params/videos.ts | 32 +++++++++--------- server/tests/api/videos/multiple-servers.ts | 2 +- .../tests/cli/create-import-video-file-job.ts | 4 +-- .../tests/{api => }/fixtures/avatar-big.png | Bin .../{api => }/fixtures/avatar-resized.png | Bin server/tests/{api => }/fixtures/avatar.png | Bin .../{api => }/fixtures/avatar2-resized.png | Bin server/tests/{api => }/fixtures/avatar2.png | Bin server/tests/{api => }/fixtures/preview.jpg | Bin server/tests/{api => }/fixtures/thumbnail.jpg | Bin .../{api => }/fixtures/video_60fps_short.mp4 | Bin .../{api => }/fixtures/video_short-480.webm | Bin .../tests/{api => }/fixtures/video_short.mp4 | Bin .../{api => }/fixtures/video_short.mp4.jpg | Bin .../tests/{api => }/fixtures/video_short.ogv | Bin .../{api => }/fixtures/video_short.ogv.jpg | Bin .../tests/{api => }/fixtures/video_short.webm | Bin .../{api => }/fixtures/video_short.webm.jpg | Bin .../fixtures/video_short1-preview.webm.jpg | Bin .../{api => }/fixtures/video_short1.webm | Bin .../{api => }/fixtures/video_short1.webm.jpg | Bin .../{api => }/fixtures/video_short2.webm | Bin .../{api => }/fixtures/video_short2.webm.jpg | Bin .../{api => }/fixtures/video_short3.webm | Bin .../{api => }/fixtures/video_short3.webm.jpg | Bin .../{api => }/fixtures/video_short_fake.webm | 0 server/tests/utils/miscs/miscs.ts | 4 +-- server/tests/utils/requests/requests.ts | 2 +- server/tests/utils/users/users.ts | 2 +- server/tests/utils/videos/videos.ts | 2 -- 31 files changed, 26 insertions(+), 28 deletions(-) rename server/tests/{api => }/fixtures/avatar-big.png (100%) rename server/tests/{api => }/fixtures/avatar-resized.png (100%) rename server/tests/{api => }/fixtures/avatar.png (100%) rename server/tests/{api => }/fixtures/avatar2-resized.png (100%) rename server/tests/{api => }/fixtures/avatar2.png (100%) rename server/tests/{api => }/fixtures/preview.jpg (100%) rename server/tests/{api => }/fixtures/thumbnail.jpg (100%) rename server/tests/{api => }/fixtures/video_60fps_short.mp4 (100%) rename server/tests/{api => }/fixtures/video_short-480.webm (100%) rename server/tests/{api => }/fixtures/video_short.mp4 (100%) rename server/tests/{api => }/fixtures/video_short.mp4.jpg (100%) rename server/tests/{api => }/fixtures/video_short.ogv (100%) rename server/tests/{api => }/fixtures/video_short.ogv.jpg (100%) rename server/tests/{api => }/fixtures/video_short.webm (100%) rename server/tests/{api => }/fixtures/video_short.webm.jpg (100%) rename server/tests/{api => }/fixtures/video_short1-preview.webm.jpg (100%) rename server/tests/{api => }/fixtures/video_short1.webm (100%) rename server/tests/{api => }/fixtures/video_short1.webm.jpg (100%) rename server/tests/{api => }/fixtures/video_short2.webm (100%) rename server/tests/{api => }/fixtures/video_short2.webm.jpg (100%) rename server/tests/{api => }/fixtures/video_short3.webm (100%) rename server/tests/{api => }/fixtures/video_short3.webm.jpg (100%) rename server/tests/{api => }/fixtures/video_short_fake.webm (100%) diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index e8a6ffd19..dba57778d 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -279,7 +279,7 @@ describe('Test users API validators', function () { it('Should fail without an incorrect input file', async function () { const fields = {} const attaches = { - 'avatarfile': join(__dirname, '..', 'fixtures', 'video_short.mp4') + 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') } await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) }) @@ -287,7 +287,7 @@ describe('Test users API validators', function () { it('Should fail with a big file', async function () { const fields = {} const attaches = { - 'avatarfile': join(__dirname, '..', 'fixtures', 'avatar-big.png') + 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') } await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches }) }) @@ -295,7 +295,7 @@ describe('Test users API validators', function () { it('Should succeed with the correct params', async function () { const fields = {} const attaches = { - 'avatarfile': join(__dirname, '..', 'fixtures', 'avatar.png') + 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') } await makeUploadRequest({ url: server.url, diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 7b40b91e7..bc6c7fc46 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -163,7 +163,7 @@ describe('Test videos API validator', function () { describe('When adding a video', function () { let baseCorrectParams const baseCorrectAttaches = { - 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') + 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.webm') } before(function () { @@ -313,7 +313,7 @@ describe('Test videos API validator', function () { it('Should fail without an incorrect input file', async function () { const fields = baseCorrectParams const attaches = { - 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') + 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) }) @@ -321,8 +321,8 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar.png'), - 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') + 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'), + 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -331,8 +331,8 @@ describe('Test videos API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar-big.png'), - 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') + 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'), + 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -341,8 +341,8 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', 'fixtures', 'avatar.png'), - 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') + 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'), + 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -351,8 +351,8 @@ describe('Test videos API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', 'fixtures', 'avatar-big.png'), - 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') + 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'), + 'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm') } await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) @@ -377,7 +377,7 @@ describe('Test videos API validator', function () { { const attaches = immutableAssign(baseCorrectAttaches, { - videofile: join(__dirname, '..', 'fixtures', 'video_short.mp4') + videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4') }) await makeUploadRequest({ @@ -392,7 +392,7 @@ describe('Test videos API validator', function () { { const attaches = immutableAssign(baseCorrectAttaches, { - videofile: join(__dirname, '..', 'fixtures', 'video_short.ogv') + videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.ogv') }) await makeUploadRequest({ @@ -510,7 +510,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar.png') + 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') } await makeUploadRequest({ @@ -526,7 +526,7 @@ describe('Test videos API validator', function () { it('Should fail with a big thumbnail file', async function () { const fields = baseCorrectParams const attaches = { - 'thumbnailfile': join(__dirname, '..', 'fixtures', 'avatar-big.png') + 'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') } await makeUploadRequest({ @@ -542,7 +542,7 @@ describe('Test videos API validator', function () { it('Should fail with an incorrect preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', 'fixtures', 'avatar.png') + 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png') } await makeUploadRequest({ @@ -558,7 +558,7 @@ describe('Test videos API validator', function () { it('Should fail with a big preview file', async function () { const fields = baseCorrectParams const attaches = { - 'previewfile': join(__dirname, '..', 'fixtures', 'avatar-big.png') + 'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png') } await makeUploadRequest({ diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index fc7c0cb21..5f9a76621 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -938,7 +938,7 @@ describe('Test multiple servers', function () { .field('channelId', '1') .field('commentsEnabled', 'true') - const filePath = join(__dirname, '..', '..', 'api', 'fixtures', 'video_short.webm') + const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') await req.attach('videofile', filePath) .expect(200) diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 251088882..372c7e517 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -59,7 +59,7 @@ describe('Test create import video jobs', function () { it('Should run a import job on video 1 with a lower resolution', async function () { const env = getEnvCli(servers[0]) - await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/api/fixtures/video_short-480.webm`) + await execCLI(`${env} npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`) await wait(30000) @@ -83,7 +83,7 @@ describe('Test create import video jobs', function () { it('Should run a import job on video 2 with the same resolution', async function () { const env = getEnvCli(servers[1]) - await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/api/fixtures/video_short.ogv`) + await execCLI(`${env} npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`) await wait(30000) diff --git a/server/tests/api/fixtures/avatar-big.png b/server/tests/fixtures/avatar-big.png similarity index 100% rename from server/tests/api/fixtures/avatar-big.png rename to server/tests/fixtures/avatar-big.png diff --git a/server/tests/api/fixtures/avatar-resized.png b/server/tests/fixtures/avatar-resized.png similarity index 100% rename from server/tests/api/fixtures/avatar-resized.png rename to server/tests/fixtures/avatar-resized.png diff --git a/server/tests/api/fixtures/avatar.png b/server/tests/fixtures/avatar.png similarity index 100% rename from server/tests/api/fixtures/avatar.png rename to server/tests/fixtures/avatar.png diff --git a/server/tests/api/fixtures/avatar2-resized.png b/server/tests/fixtures/avatar2-resized.png similarity index 100% rename from server/tests/api/fixtures/avatar2-resized.png rename to server/tests/fixtures/avatar2-resized.png diff --git a/server/tests/api/fixtures/avatar2.png b/server/tests/fixtures/avatar2.png similarity index 100% rename from server/tests/api/fixtures/avatar2.png rename to server/tests/fixtures/avatar2.png diff --git a/server/tests/api/fixtures/preview.jpg b/server/tests/fixtures/preview.jpg similarity index 100% rename from server/tests/api/fixtures/preview.jpg rename to server/tests/fixtures/preview.jpg diff --git a/server/tests/api/fixtures/thumbnail.jpg b/server/tests/fixtures/thumbnail.jpg similarity index 100% rename from server/tests/api/fixtures/thumbnail.jpg rename to server/tests/fixtures/thumbnail.jpg diff --git a/server/tests/api/fixtures/video_60fps_short.mp4 b/server/tests/fixtures/video_60fps_short.mp4 similarity index 100% rename from server/tests/api/fixtures/video_60fps_short.mp4 rename to server/tests/fixtures/video_60fps_short.mp4 diff --git a/server/tests/api/fixtures/video_short-480.webm b/server/tests/fixtures/video_short-480.webm similarity index 100% rename from server/tests/api/fixtures/video_short-480.webm rename to server/tests/fixtures/video_short-480.webm diff --git a/server/tests/api/fixtures/video_short.mp4 b/server/tests/fixtures/video_short.mp4 similarity index 100% rename from server/tests/api/fixtures/video_short.mp4 rename to server/tests/fixtures/video_short.mp4 diff --git a/server/tests/api/fixtures/video_short.mp4.jpg b/server/tests/fixtures/video_short.mp4.jpg similarity index 100% rename from server/tests/api/fixtures/video_short.mp4.jpg rename to server/tests/fixtures/video_short.mp4.jpg diff --git a/server/tests/api/fixtures/video_short.ogv b/server/tests/fixtures/video_short.ogv similarity index 100% rename from server/tests/api/fixtures/video_short.ogv rename to server/tests/fixtures/video_short.ogv diff --git a/server/tests/api/fixtures/video_short.ogv.jpg b/server/tests/fixtures/video_short.ogv.jpg similarity index 100% rename from server/tests/api/fixtures/video_short.ogv.jpg rename to server/tests/fixtures/video_short.ogv.jpg diff --git a/server/tests/api/fixtures/video_short.webm b/server/tests/fixtures/video_short.webm similarity index 100% rename from server/tests/api/fixtures/video_short.webm rename to server/tests/fixtures/video_short.webm diff --git a/server/tests/api/fixtures/video_short.webm.jpg b/server/tests/fixtures/video_short.webm.jpg similarity index 100% rename from server/tests/api/fixtures/video_short.webm.jpg rename to server/tests/fixtures/video_short.webm.jpg diff --git a/server/tests/api/fixtures/video_short1-preview.webm.jpg b/server/tests/fixtures/video_short1-preview.webm.jpg similarity index 100% rename from server/tests/api/fixtures/video_short1-preview.webm.jpg rename to server/tests/fixtures/video_short1-preview.webm.jpg diff --git a/server/tests/api/fixtures/video_short1.webm b/server/tests/fixtures/video_short1.webm similarity index 100% rename from server/tests/api/fixtures/video_short1.webm rename to server/tests/fixtures/video_short1.webm diff --git a/server/tests/api/fixtures/video_short1.webm.jpg b/server/tests/fixtures/video_short1.webm.jpg similarity index 100% rename from server/tests/api/fixtures/video_short1.webm.jpg rename to server/tests/fixtures/video_short1.webm.jpg diff --git a/server/tests/api/fixtures/video_short2.webm b/server/tests/fixtures/video_short2.webm similarity index 100% rename from server/tests/api/fixtures/video_short2.webm rename to server/tests/fixtures/video_short2.webm diff --git a/server/tests/api/fixtures/video_short2.webm.jpg b/server/tests/fixtures/video_short2.webm.jpg similarity index 100% rename from server/tests/api/fixtures/video_short2.webm.jpg rename to server/tests/fixtures/video_short2.webm.jpg diff --git a/server/tests/api/fixtures/video_short3.webm b/server/tests/fixtures/video_short3.webm similarity index 100% rename from server/tests/api/fixtures/video_short3.webm rename to server/tests/fixtures/video_short3.webm diff --git a/server/tests/api/fixtures/video_short3.webm.jpg b/server/tests/fixtures/video_short3.webm.jpg similarity index 100% rename from server/tests/api/fixtures/video_short3.webm.jpg rename to server/tests/fixtures/video_short3.webm.jpg diff --git a/server/tests/api/fixtures/video_short_fake.webm b/server/tests/fixtures/video_short_fake.webm similarity index 100% rename from server/tests/api/fixtures/video_short_fake.webm rename to server/tests/fixtures/video_short_fake.webm diff --git a/server/tests/utils/miscs/miscs.ts b/server/tests/utils/miscs/miscs.ts index 53cb67baf..5e46004a7 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/server/tests/utils/miscs/miscs.ts @@ -46,7 +46,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext const body = res.body - const data = await readFileBufferPromise(join(__dirname, '..', '..', 'api', 'fixtures', imageName + extension)) + const data = await readFileBufferPromise(join(__dirname, '..', '..', 'fixtures', imageName + extension)) const minLength = body.length - ((20 * body.length) / 100) const maxLength = body.length + ((20 * body.length) / 100) @@ -63,7 +63,7 @@ function buildAbsoluteFixturePath (path: string) { return path } - return join(__dirname, '..', '..', 'api', 'fixtures', path) + return join(__dirname, '..', '..', 'fixtures', path) } // --------------------------------------------------------------------------- diff --git a/server/tests/utils/requests/requests.ts b/server/tests/utils/requests/requests.ts index a9b1dff9a..b6195089d 100644 --- a/server/tests/utils/requests/requests.ts +++ b/server/tests/utils/requests/requests.ts @@ -1,5 +1,5 @@ import * as request from 'supertest' -import { buildAbsoluteFixturePath } from '../' +import { buildAbsoluteFixturePath } from '../miscs/miscs' function makeGetRequest (options: { url: string, diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index d31e57a25..34d50f7ad 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts @@ -164,7 +164,7 @@ function updateMyAvatar (options: { if (isAbsolute(options.fixture)) { filePath = options.fixture } else { - filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture) + filePath = join(__dirname, '..', '..', 'fixtures', options.fixture) } return makeUploadRequest({ diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts index 746b5ca6b..ab0ce12ec 100644 --- a/server/tests/utils/videos/videos.ts +++ b/server/tests/utils/videos/videos.ts @@ -502,8 +502,6 @@ async function completeVideoCheck ( expect(dateIsValid(video.updatedAt)).to.be.true if (attributes.publishedAt) { - console.log(attributes.publishedAt) - console.log(video.publishedAt) expect(video.publishedAt).to.equal(attributes.publishedAt) } -- 2.25.1