mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-17 11:16:26 -07:00
Add Tdarr_Plugin_a9he_New_file_size_check test
This commit is contained in:
parent
7dcee9b1ae
commit
3032997079
3 changed files with 93 additions and 9 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
// tdarrSkipTest
|
|
||||||
const details = () => ({
|
const details = () => ({
|
||||||
id: 'Tdarr_Plugin_a9he_New_file_size_check',
|
id: 'Tdarr_Plugin_a9he_New_file_size_check',
|
||||||
Stage: 'Pre-processing',
|
Stage: 'Pre-processing',
|
||||||
|
|
|
||||||
67
tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js
Normal file
67
tests/Community/Tdarr_Plugin_a9he_New_file_size_check.js
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
/* eslint max-len: 0 */
|
||||||
|
const run = require('../helpers/run');
|
||||||
|
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: require('../sampleData/media/sampleH264_1.json'),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {},
|
||||||
|
otherArguments: {
|
||||||
|
originalLibraryFile: require('../sampleData/media/sampleH264_1.json'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
processFile: false,
|
||||||
|
preset: '',
|
||||||
|
handBrakeMode: false,
|
||||||
|
FFmpegMode: true,
|
||||||
|
reQueueAfter: true,
|
||||||
|
infoLog: 'New file has size 1.008 MB which is 100% of original file size: 1.008 MB',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: require('../sampleData/media/sampleH264_1.json'),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
upperBound: '110',
|
||||||
|
lowerBound: '35',
|
||||||
|
},
|
||||||
|
otherArguments: {
|
||||||
|
originalLibraryFile: (() => {
|
||||||
|
const file = JSON.parse(JSON.stringify(require('../sampleData/media/sampleH264_1.json')));
|
||||||
|
file.file_size = 3;
|
||||||
|
return file;
|
||||||
|
})(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: 'New file size not within limits. New file has size 1.008 MB which is 33% of original file size: 3.000 MB. lowerBound is 35%',
|
||||||
|
error: {
|
||||||
|
shouldThrow: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {
|
||||||
|
file: require('../sampleData/media/sampleH264_1.json'),
|
||||||
|
librarySettings: {},
|
||||||
|
inputs: {
|
||||||
|
upperBound: '120',
|
||||||
|
lowerBound: '35',
|
||||||
|
},
|
||||||
|
otherArguments: {
|
||||||
|
originalLibraryFile: (() => {
|
||||||
|
const file = JSON.parse(JSON.stringify(require('../sampleData/media/sampleH264_1.json')));
|
||||||
|
file.file_size = 0.1;
|
||||||
|
return file;
|
||||||
|
})(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
output: 'New file size not within limits. New file has size 1.008 MB which is 1007% of original file size: 0.100 MB. upperBound is 120%',
|
||||||
|
error: {
|
||||||
|
shouldThrow: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
run(tests);
|
||||||
|
|
@ -15,14 +15,32 @@ const run = async (tests) => {
|
||||||
if (typeof test.input.file === 'function') {
|
if (typeof test.input.file === 'function') {
|
||||||
file = test.input.file();
|
file = test.input.file();
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-await-in-loop
|
|
||||||
const testOutput = await plugin(
|
let testOutput;
|
||||||
file,
|
let errorEncountered = false;
|
||||||
test.input.librarySettings,
|
try {
|
||||||
test.input.inputs,
|
// eslint-disable-next-line no-await-in-loop
|
||||||
test.input.otherArguments,
|
testOutput = await plugin(
|
||||||
);
|
file,
|
||||||
chai.assert.deepEqual(testOutput, test.output);
|
test.input.librarySettings,
|
||||||
|
test.input.inputs,
|
||||||
|
test.input.otherArguments,
|
||||||
|
);
|
||||||
|
} catch (err1) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(err1);
|
||||||
|
errorEncountered = err1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (test.error && test.error.shouldThrow) {
|
||||||
|
if (errorEncountered !== false) {
|
||||||
|
chai.assert.deepEqual(errorEncountered.message, test.output);
|
||||||
|
} else {
|
||||||
|
throw new Error('Expected plugin error but none was thrown!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
chai.assert.deepEqual(testOutput, test.output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue