From e11f68a3562d2468480c396f47f1bdd2a306e17a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 8 Dec 2017 10:08:36 +0100 Subject: Optimise transaction for video upload --- server/tests/api/single-server.ts | 13 +++++-------- server/tests/utils/videos.ts | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'server/tests') diff --git a/server/tests/api/single-server.ts b/server/tests/api/single-server.ts index ed79f9e1c..e99955ef4 100644 --- a/server/tests/api/single-server.ts +++ b/server/tests/api/single-server.ts @@ -364,7 +364,7 @@ describe('Test a single server', function () { 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' ] - // const tasks: Promise[] = [] + const tasks: Promise[] = [] for (const video of videos) { const videoAttributes = { name: video + ' name', @@ -378,13 +378,10 @@ describe('Test a single server', function () { } const p = uploadVideo(server.url, server.accessToken, videoAttributes) - await p + tasks.push(p) } - // FIXME: concurrent uploads does not work :( - // tasks.push(p) - // } - // - // await Promise.all(tasks) + + await Promise.all(tasks) }) it('Should have the correct durations', async function () { @@ -712,7 +709,7 @@ describe('Test a single server', function () { const filePath = join(__dirname, '..', 'api', 'fixtures', 'video_short.webm') await req.attach('videofile', filePath) - .expect(204) + .expect(200) const res = await getVideosList(server.url) const video = res.body.data.find(v => v.name === 'minimum parameters') diff --git a/server/tests/utils/videos.ts b/server/tests/utils/videos.ts index bdf3368ac..fb758cf29 100644 --- a/server/tests/utils/videos.ts +++ b/server/tests/utils/videos.ts @@ -201,7 +201,7 @@ async function testVideoImage (url: string, imageName: string, imagePath: string } } -async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 201) { +async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 200) { const path = '/api/v1/videos/upload' let defaultChannelId = '1' -- cgit v1.2.3