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()
expect(await pathExists(join(base, filePath))).to.equal(exist)
}
+// ---------------------------------------------------------------------------
+
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
return makeGetRequest({
url,
})
}
+// ---------------------------------------------------------------------------
+
+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,
checkBadStartPagination,
checkBadCountPagination,
checkBadSortPagination,
+ checkVideoDuration,
expectLogContain
}