eslint: add no-shadow
This commit is contained in:
+13
-13
@@ -82,42 +82,42 @@ describe('task', function () {
|
||||
});
|
||||
|
||||
it('can run valid task - success', async function () {
|
||||
const taskId = await tasks.add(tasks._TASK_IDENTITY, [ 'ping' ]);
|
||||
const successTaskId = await tasks.add(tasks._TASK_IDENTITY, [ 'ping' ]);
|
||||
|
||||
const [error, result] = await safe(tasks.startTask(taskId, {}));
|
||||
const [error, result] = await safe(tasks.startTask(successTaskId, {}));
|
||||
if (error) throw error;
|
||||
expect(result).to.equal('ping');
|
||||
});
|
||||
|
||||
it('can run valid task - error', async function () {
|
||||
const taskId = await tasks.add(tasks._TASK_ERROR, [ 'ping' ]);
|
||||
const errorTaskId = await tasks.add(tasks._TASK_ERROR, [ 'ping' ]);
|
||||
|
||||
const [error, result] = await safe(tasks.startTask(taskId, {}));
|
||||
const [error, result] = await safe(tasks.startTask(errorTaskId, {}));
|
||||
if (!error) throw new Error('expecting task to fail');
|
||||
expect(error.message).to.be('Task crashed. Failed for arg: ping');
|
||||
expect(result).to.not.be.ok();
|
||||
});
|
||||
|
||||
it('can get logs of crash', async function () {
|
||||
const taskId = await tasks.add(tasks._TASK_CRASH, [ 'ping' ]);
|
||||
const crashTaskId = await tasks.add(tasks._TASK_CRASH, [ 'ping' ]);
|
||||
|
||||
const [error, result] = await safe(tasks.startTask(taskId, {}));
|
||||
const [error, result] = await safe(tasks.startTask(crashTaskId, {}));
|
||||
if (!error) throw new Error('expecting task to crash');
|
||||
expect(error.message).to.contain(`Task ${taskId} crashed`);
|
||||
expect(error.message).to.contain(`Task ${crashTaskId} crashed`);
|
||||
expect(result).to.not.be.ok();
|
||||
|
||||
const logs = fs.readFileSync(`${paths.TASKS_LOG_DIR}/${taskId}.log`, 'utf8');
|
||||
const logs = fs.readFileSync(`${paths.TASKS_LOG_DIR}/${crashTaskId}.log`, 'utf8');
|
||||
expect(logs).to.contain('Crashing for arg: ping');
|
||||
});
|
||||
|
||||
it('can stop task', async function () {
|
||||
const taskId = await tasks.add(tasks._TASK_SLEEP, [ 10000 ]);
|
||||
const sleepTaskId = await tasks.add(tasks._TASK_SLEEP, [ 10000 ]);
|
||||
|
||||
setTimeout(async function () {
|
||||
await tasks.stopTask(taskId);
|
||||
await tasks.stopTask(sleepTaskId);
|
||||
}, 2000);
|
||||
|
||||
const [error, result] = await safe(tasks.startTask(taskId, {}));
|
||||
const [error, result] = await safe(tasks.startTask(sleepTaskId, {}));
|
||||
if (!error) throw new Error('expecting task to stop');
|
||||
expect(error.message).to.contain('stopped');
|
||||
expect(error.code).to.be(tasks.ESTOPPED);
|
||||
@@ -125,9 +125,9 @@ describe('task', function () {
|
||||
});
|
||||
|
||||
it('task timesout', async function () {
|
||||
const taskId = await tasks.add(tasks._TASK_SLEEP, [ 10000 ]);
|
||||
const timeoutTaskId = await tasks.add(tasks._TASK_SLEEP, [ 10000 ]);
|
||||
|
||||
const [error, result] = await safe(tasks.startTask(taskId, { timeout: 2000 }));
|
||||
const [error, result] = await safe(tasks.startTask(timeoutTaskId, { timeout: 2000 }));
|
||||
if (!error) throw new Error('expecting task to timeout');
|
||||
expect(error.code).to.be(tasks.ETIMEOUT);
|
||||
expect(error.message).to.contain('timed out');
|
||||
|
||||
Reference in New Issue
Block a user