Fix tasks test
This commit is contained in:
@@ -34,10 +34,11 @@ const TASKS = { // indexed by task type
|
||||
syncDnsRecords: dns.syncDnsRecords,
|
||||
syncDyndns: dyndns.sync,
|
||||
|
||||
_identity: async (arg, progressCallback) => { progressCallback({ percent: 20 }); return arg; },
|
||||
_error: async (arg, progressCallback) => { progressCallback({ percent: 20 }); throw new Error(`Failed for arg: ${arg}`); },
|
||||
_crash: (arg) => { throw new Error(`Crashing for arg: ${arg}`); }, // the test looks for this debug string in the log file
|
||||
_sleep: async (arg) => await timers.setTimeout(parseInt(arg, 10))
|
||||
// testing
|
||||
identity: async (arg, progressCallback) => { progressCallback({ percent: 20 }); return arg; },
|
||||
error: async (arg, progressCallback) => { progressCallback({ percent: 20 }); throw new Error(`Failed for arg: ${arg}`); },
|
||||
crash: (arg) => { throw new Error(`Crashing for arg: ${arg}`); }, // the test looks for this debug string in the log file
|
||||
sleep: async (arg) => await timers.setTimeout(parseInt(arg, 10))
|
||||
};
|
||||
|
||||
if (process.argv.length !== 4) {
|
||||
@@ -117,8 +118,9 @@ async function main() {
|
||||
await safe(tasks.update(taskId, progress), { debug });
|
||||
}
|
||||
|
||||
debug(`Running task of type ${task.type}`);
|
||||
const [runError, result] = await safe(TASKS[task.type.replace(/_.*/,'')].apply(null, task.args.concat(progressCallback)));
|
||||
const taskName = task.type.replace(/_.*/,'');
|
||||
debug(`Running task of type ${taskName}`);
|
||||
const [runError, result] = await safe(TASKS[taskName].apply(null, task.args.concat(progressCallback)));
|
||||
const progress = {
|
||||
result: result || null,
|
||||
error: runError ? toTaskError(runError) : null,
|
||||
|
||||
Reference in New Issue
Block a user