Add Tdarr_Plugin_a9he_New_file_size_check test

make-only-subtitle-default
HaveAGitGat 4 years ago
parent 7dcee9b1ae
commit 3032997079

@ -1,4 +1,3 @@
// tdarrSkipTest
const details = () => ({
id: 'Tdarr_Plugin_a9he_New_file_size_check',
Stage: 'Pre-processing',

@ -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,15 +15,33 @@ const run = async (tests) => {
if (typeof test.input.file === 'function') {
file = test.input.file();
}
let testOutput;
let errorEncountered = false;
try {
// eslint-disable-next-line no-await-in-loop
const testOutput = await plugin(
testOutput = await plugin(
file,
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) {
// eslint-disable-next-line no-console
console.error(err);

Loading…
Cancel
Save