aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-08 10:35:49 +0200
committerChocobozzz <me@florianbigard.com>2021-04-08 13:38:04 +0200
commita0eeb45f14bab539f505861cad8f5d42d9ba30cb (patch)
tree773eb5aa575c8ab870b9c84f686e6062aa58d9fd /server/tests
parentca873292899c9a822a236556993916d98da14913 (diff)
downloadPeerTube-a0eeb45f14bab539f505861cad8f5d42d9ba30cb.tar.gz
PeerTube-a0eeb45f14bab539f505861cad8f5d42d9ba30cb.tar.zst
PeerTube-a0eeb45f14bab539f505861cad8f5d42d9ba30cb.zip
Update data in DB when regenerate thumbnails
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts32
1 files changed, 23 insertions, 9 deletions
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index a9c8642a5..8acb9f263 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -2,7 +2,7 @@ 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 } from '@shared/models' 5import { Video, VideoDetails } from '@shared/models'
6import { 6import {
7 buildServerDirectory, 7 buildServerDirectory,
8 cleanupTests, 8 cleanupTests,
@@ -19,6 +19,17 @@ import {
19} from '../../../shared/extra-utils' 19} from '../../../shared/extra-utils'
20import { HttpStatusCode } from '@shared/core-utils' 20import { HttpStatusCode } from '@shared/core-utils'
21 21
22async function testThumbnail (server: ServerInfo, videoId: number | string) {
23 const res = await getVideo(server.url, videoId)
24 const video: VideoDetails = res.body
25
26 const res1 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200)
27 expect(res1.body).to.not.have.lengthOf(0)
28
29 const res2 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200)
30 expect(res2.body).to.not.have.lengthOf(0)
31}
32
22describe('Test regenerate thumbnails script', function () { 33describe('Test regenerate thumbnails script', function () {
23 let servers: ServerInfo[] 34 let servers: ServerInfo[]
24 35
@@ -84,18 +95,21 @@ describe('Test regenerate thumbnails script', function () {
84 await execCLI(`${env} npm run regenerate-thumbnails`) 95 await execCLI(`${env} npm run regenerate-thumbnails`)
85 }) 96 })
86 97
87 it('Should have regenerated local thumbnails', async function () { 98 it('Should have generated new thumbnail files', async function () {
88 { 99 await testThumbnail(servers[0], video1.uuid)
89 const res1 = await makeRawRequest(join(servers[0].url, video1.thumbnailPath), HttpStatusCode.OK_200) 100 await testThumbnail(servers[0], video2.uuid)
90 expect(res1.body).to.not.have.lengthOf(0)
91 101
92 const res2 = await makeRawRequest(join(servers[0].url, video1.previewPath), HttpStatusCode.OK_200) 102 const res = await makeRawRequest(join(servers[0].url, remoteVideo.thumbnailPath), HttpStatusCode.OK_200)
93 expect(res2.body).to.not.have.lengthOf(0) 103 expect(res.body).to.have.lengthOf(0)
104 })
105
106 it('Should have deleted old thumbnail files', async function () {
107 {
108 await makeRawRequest(join(servers[0].url, video1.thumbnailPath), HttpStatusCode.NOT_FOUND_404)
94 } 109 }
95 110
96 { 111 {
97 const res = await makeRawRequest(join(servers[0].url, video2.thumbnailPath), HttpStatusCode.OK_200) 112 await makeRawRequest(join(servers[0].url, video2.thumbnailPath), HttpStatusCode.NOT_FOUND_404)
98 expect(res.body).to.not.have.lengthOf(0)
99 } 113 }
100 114
101 { 115 {