From 2055962c844e557d628d9d0aae9303590c39eab8 Mon Sep 17 00:00:00 2001 From: Seth Falco Date: Wed, 2 Aug 2023 23:22:36 +0100 Subject: fix: handle git installation of ffmpeg --- packages/tests/src/server-helpers/core-utils.ts | 53 ++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'packages/tests/src') diff --git a/packages/tests/src/server-helpers/core-utils.ts b/packages/tests/src/server-helpers/core-utils.ts index 06c78591e..d61cae855 100644 --- a/packages/tests/src/server-helpers/core-utils.ts +++ b/packages/tests/src/server-helpers/core-utils.ts @@ -5,7 +5,7 @@ import snakeCase from 'lodash-es/snakeCase.js' import validator from 'validator' import { getAverageTheoreticalBitrate, getMaxTheoreticalBitrate } from '@peertube/peertube-core-utils' import { VideoResolution } from '@peertube/peertube-models' -import { objectConverter, parseBytes, parseDurationToMs } from '@peertube/peertube-server/server/helpers/core-utils.js' +import { objectConverter, parseBytes, parseDurationToMs, parseSemVersion } from '@peertube/peertube-server/server/helpers/core-utils.js' describe('Parse Bytes', function () { @@ -148,3 +148,54 @@ describe('Bitrate', function () { } }) }) + +describe('Parse semantic version string', function () { + + it('Should parse Node.js version string', function () { + const actual = parseSemVersion('v18.16.0') + + expect(actual.major).to.equal(18) + expect(actual.minor).to.equal(16) + expect(actual.patch).to.equal(0) + }) + + it('Should parse FFmpeg version string from Debian 12 repo', function () { + const actual = parseSemVersion('5.1.3-1') + + expect(actual.major).to.equal(5) + expect(actual.minor).to.equal(1) + expect(actual.patch).to.equal(3) + }) + + it('Should parse FFmpeg version string from Arch repo', function () { + const actual = parseSemVersion('n6.0') + + expect(actual.major).to.equal(6) + expect(actual.minor).to.equal(0) + expect(actual.patch).to.equal(0) + }) + + it('Should parse FFmpeg version from GitHub release', function () { + const actual = parseSemVersion('5.1.3') + + expect(actual.major).to.equal(5) + expect(actual.minor).to.equal(1) + expect(actual.patch).to.equal(3) + }) + + it('Should parse FFmpeg version from GitHub dev release', function () { + const actual = parseSemVersion('5.1.git') + + expect(actual.major).to.equal(5) + expect(actual.minor).to.equal(1) + expect(actual.patch).to.equal(0) + }) + + it('Should parse FFmpeg version string with missing patch segment', function () { + const actual = parseSemVersion('4.4') + + expect(actual.major).to.equal(4) + expect(actual.minor).to.equal(4) + expect(actual.patch).to.equal(0) + }) +}) -- cgit v1.2.3