X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fcli%2Fregenerate-thumbnails.ts;h=8acb9f263b2b649dd926b5f46e7cd4d20e98b647;hb=d4a8e7a65f97bb3257facc13e1ae8ffdbad61ddb;hp=56005518a0350bf39790c0489e4fb65347bdfbee;hpb=e62f03ae0412f4efa62917d8741bc1a39e8ed7fc;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index 56005518a..8acb9f263 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' import { writeFile } from 'fs-extra' import { basename, join } from 'path' -import { Video } from '@shared/models' +import { Video, VideoDetails } from '@shared/models' import { buildServerDirectory, cleanupTests, @@ -19,6 +19,17 @@ import { } from '../../../shared/extra-utils' import { HttpStatusCode } from '@shared/core-utils' +async function testThumbnail (server: ServerInfo, videoId: number | string) { + const res = await getVideo(server.url, videoId) + const video: VideoDetails = res.body + + const res1 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) + expect(res1.body).to.not.have.lengthOf(0) + + const res2 = await makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200) + expect(res2.body).to.not.have.lengthOf(0) +} + describe('Test regenerate thumbnails script', function () { let servers: ServerInfo[] @@ -77,25 +88,28 @@ describe('Test regenerate thumbnails script', function () { } }) - it('Should regenerate thumbnails from the CLI', async function () { + it('Should regenerate local thumbnails from the CLI', async function () { this.timeout(15000) const env = getEnvCli(servers[0]) await execCLI(`${env} npm run regenerate-thumbnails`) }) - it('Should have regenerated thumbbnails', async function () { - { - const res1 = await makeRawRequest(join(servers[0].url, video1.thumbnailPath), HttpStatusCode.OK_200) - expect(res1.body).to.not.have.lengthOf(0) + it('Should have generated new thumbnail files', async function () { + await testThumbnail(servers[0], video1.uuid) + await testThumbnail(servers[0], video2.uuid) - const res2 = await makeRawRequest(join(servers[0].url, video1.previewPath), HttpStatusCode.OK_200) - expect(res2.body).to.not.have.lengthOf(0) + const res = await makeRawRequest(join(servers[0].url, remoteVideo.thumbnailPath), HttpStatusCode.OK_200) + expect(res.body).to.have.lengthOf(0) + }) + + it('Should have deleted old thumbnail files', async function () { + { + await makeRawRequest(join(servers[0].url, video1.thumbnailPath), HttpStatusCode.NOT_FOUND_404) } { - const res = await makeRawRequest(join(servers[0].url, video2.thumbnailPath), HttpStatusCode.OK_200) - expect(res.body).to.not.have.lengthOf(0) + await makeRawRequest(join(servers[0].url, video2.thumbnailPath), HttpStatusCode.NOT_FOUND_404) } {