X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fshared%2Fchecks.ts;h=feaef37c67ab43cad6e1f0dc7bf449e7b931b2f2;hb=4cf800a350972a078c074da6b31da2b98ab4b007;hp=c0098b293851a50299fab61647193dcd60a3b4f7;hpb=d41f4a6dc69d098e9dc9173b7e1a586695ef7b97;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/shared/checks.ts b/server/tests/shared/checks.ts index c0098b293..feaef37c6 100644 --- a/server/tests/shared/checks.ts +++ b/server/tests/shared/checks.ts @@ -11,7 +11,7 @@ import { HttpStatusCode } from '@shared/models' import { makeGetRequest, PeerTubeServer } from '@shared/server-commands' // Default interval -> 5 minutes -function dateIsValid (dateString: string, interval = 300000) { +function dateIsValid (dateString: string | Date, interval = 300000) { const dateToCheck = new Date(dateString) const now = new Date() @@ -90,6 +90,8 @@ async function testFileExistsOrNot (server: PeerTubeServer, directory: string, f expect(await pathExists(join(base, filePath))).to.equal(exist) } +// --------------------------------------------------------------------------- + function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { return makeGetRequest({ url, @@ -128,6 +130,22 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer }) } +// --------------------------------------------------------------------------- + +async function checkVideoDuration (server: PeerTubeServer, videoUUID: string, duration: number) { + const video = await server.videos.get({ id: videoUUID }) + + expect(video.duration).to.be.approximately(duration, 1) + + for (const file of video.files) { + const metadata = await server.videos.getFileMetadata({ url: file.metadataUrl }) + + for (const stream of metadata.streams) { + expect(Math.round(stream.duration)).to.be.approximately(duration, 1) + } + } +} + export { dateIsValid, testImageSize, @@ -140,5 +158,6 @@ export { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination, + checkVideoDuration, expectLogContain }