From ad646d04b5f74c99580b63370f532f6388dd518d Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Mon, 23 May 2022 07:17:18 +0100 Subject: [PATCH] Add Tdarr_Plugin_a9hf_New_file_duration_check test --- .../Tdarr_Plugin_a9he_New_file_size_check.js | 1 + ...arr_Plugin_a9hf_New_file_duration_check.js | 1 - .../Tdarr_Plugin_a9he_New_file_size_check.js | 8 +-- ...arr_Plugin_a9hf_New_file_duration_check.js | 68 +++++++++++++++++++ 4 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js diff --git a/Community/Tdarr_Plugin_a9he_New_file_size_check.js b/Community/Tdarr_Plugin_a9he_New_file_size_check.js index 32e99d6..c352eba 100644 --- a/Community/Tdarr_Plugin_a9he_New_file_size_check.js +++ b/Community/Tdarr_Plugin_a9he_New_file_size_check.js @@ -52,6 +52,7 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { const ratio = parseInt((newSize / oldSize) * 100, 10); + console.log(newSize, oldSize); const sizeText = `New file has size ${newSize.toFixed(3)} MB which is ${ratio}% ` + `of original file size: ${oldSize.toFixed(3)} MB`; diff --git a/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js b/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js index 6f1fcc5..4cda5ca 100644 --- a/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js +++ b/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js @@ -1,6 +1,5 @@ // eslint-disable-next-line import/no-unresolved -// tdarrSkipTest const details = () => ({ id: 'Tdarr_Plugin_a9hf_New_file_duration_check', Stage: 'Pre-processing', diff --git a/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js b/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js index 7e1de0d..e990b36 100644 --- a/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js +++ b/tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js @@ -5,11 +5,11 @@ const run = require('../helpers/run'); const tests = [ { input: { - file: require('../sampleData/media/sampleH264_1.json'), + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), librarySettings: {}, inputs: {}, otherArguments: { - originalLibraryFile: require('../sampleData/media/sampleH264_1.json'), + originalLibraryFile: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), }, }, output: { @@ -23,7 +23,7 @@ const tests = [ }, { input: { - file: require('../sampleData/media/sampleH264_1.json'), + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), librarySettings: {}, inputs: { upperBound: '110', @@ -44,7 +44,7 @@ const tests = [ }, { input: { - file: require('../sampleData/media/sampleH264_1.json'), + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), librarySettings: {}, inputs: { upperBound: '120', diff --git a/tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js b/tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js new file mode 100644 index 0000000..9497714 --- /dev/null +++ b/tests/Community/Tdarr_Plugin_a9hf_New_file_duration_check.js @@ -0,0 +1,68 @@ +/* eslint max-len: 0 */ +const _ = require('lodash'); +const run = require('../helpers/run'); + +const tests = [ + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: {}, + otherArguments: { + originalLibraryFile: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + }, + }, + output: { + processFile: false, + preset: '', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: 'New file has duration 5.312 s which is 100.000% of original file duration: 5.312 s', + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: { + upperBound: '110', + lowerBound: '35', + }, + otherArguments: { + originalLibraryFile: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.mediaInfo.track.filter((row) => row['@type'] === 'General')[0].Duration = 20; + return file; + })(), + }, + }, + output: 'New file duration not within limits. New file has duration 5.312 s which is 26.560% of original file duration: 20 s. lowerBound is 35%', + error: { + shouldThrow: true, + }, + }, + { + input: { + file: _.cloneDeep(require('../sampleData/media/sampleH264_1.json')), + librarySettings: {}, + inputs: { + upperBound: '110', + lowerBound: '35', + }, + otherArguments: { + originalLibraryFile: (() => { + const file = _.cloneDeep(require('../sampleData/media/sampleH264_1.json')); + file.mediaInfo.track.filter((row) => row['@type'] === 'General')[0].Duration = 1; + return file; + })(), + }, + }, + output: 'New file duration not within limits. New file has duration 5.312 s which is 531.200% of original file duration: 1 s. upperBound is 110%', + error: { + shouldThrow: true, + }, + }, +]; + +run(tests);