aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/cli/regenerate-thumbnails.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/cli/regenerate-thumbnails.ts
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/cli/regenerate-thumbnails.ts')
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts33
1 files changed, 17 insertions, 16 deletions
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index 68a4711b6..d59520783 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -2,29 +2,30 @@ import 'mocha'
2import { expect } from 'chai' 2import { expect } from 'chai'
3import { writeFile } from 'fs-extra' 3import { writeFile } from 'fs-extra'
4import { basename, join } from 'path' 4import { basename, join } from 'path'
5import { Video, VideoDetails } from '@shared/models' 5import { HttpStatusCode } from '@shared/core-utils'
6import { Video } from '@shared/models'
6import { 7import {
7 cleanupTests, 8 cleanupTests,
8 doubleFollow, 9 doubleFollow,
9 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
10 getVideo,
11 makeRawRequest, 11 makeRawRequest,
12 ServerInfo, 12 ServerInfo,
13 setAccessTokensToServers, 13 setAccessTokensToServers,
14 uploadVideoAndGetId,
15 waitJobs 14 waitJobs
16} from '../../../shared/extra-utils' 15} from '../../../shared/extra-utils'
17import { HttpStatusCode } from '@shared/core-utils'
18 16
19async function testThumbnail (server: ServerInfo, videoId: number | string) { 17async function testThumbnail (server: ServerInfo, videoId: number | string) {
20 const res = await getVideo(server.url, videoId) 18 const video = await server.videosCommand.get({ id: videoId })
21 const video: VideoDetails = res.body
22 19
23 const res1 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) 20 const requests = [
24 expect(res1.body).to.not.have.lengthOf(0) 21 makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200),
22 makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200)
23 ]
25 24
26 const res2 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) 25 for (const req of requests) {
27 expect(res2.body).to.not.have.lengthOf(0) 26 const res = await req
27 expect(res.body).to.not.have.lengthOf(0)
28 }
28} 29}
29 30
30describe('Test regenerate thumbnails script', function () { 31describe('Test regenerate thumbnails script', function () {
@@ -46,20 +47,20 @@ describe('Test regenerate thumbnails script', function () {
46 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
47 48
48 { 49 {
49 const videoUUID1 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 1' })).uuid 50 const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid
50 video1 = await (getVideo(servers[0].url, videoUUID1).then(res => res.body)) 51 video1 = await servers[0].videosCommand.get({ id: videoUUID1 })
51 52
52 thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) 53 thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
53 54
54 const videoUUID2 = (await uploadVideoAndGetId({ server: servers[0], videoName: 'video 2' })).uuid 55 const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid
55 video2 = await (getVideo(servers[0].url, videoUUID2).then(res => res.body)) 56 video2 = await servers[0].videosCommand.get({ id: videoUUID2 })
56 } 57 }
57 58
58 { 59 {
59 const videoUUID = (await uploadVideoAndGetId({ server: servers[1], videoName: 'video 3' })).uuid 60 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid
60 await waitJobs(servers) 61 await waitJobs(servers)
61 62
62 remoteVideo = await (getVideo(servers[0].url, videoUUID).then(res => res.body)) 63 remoteVideo = await servers[0].videosCommand.get({ id: videoUUID })
63 64
64 thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) 65 thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
65 } 66 }