Skip to content

Commit

Permalink
Merge pull request #150 from lifeomic/task-retry
Browse files Browse the repository at this point in the history
Added retry task command
  • Loading branch information
mschroering authored Aug 7, 2020
2 parents f0cb100 + cecfb75 commit ac3868c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [11.6.0] - 2020-08-07

### Added

- Added a `lo tasks retry <taskId>` command.

## [11.5.0] - 2020-08-03

### Added
Expand Down Expand Up @@ -764,6 +770,7 @@ and `create-nantomics-vcf-import`

- Replaced the `defaults` command with a `setup` command

[11.6.0]: https://github.com/lifeomic/cli/compare/v11.5.0...v11.6.0
[11.5.0]: https://github.com/lifeomic/cli/compare/v11.4.0...v11.5.0
[11.4.0]: https://github.com/lifeomic/cli/compare/v11.3.0...v11.4.0
[11.3.0]: https://github.com/lifeomic/cli/compare/v11.2.0...v11.3.0
Expand Down
20 changes: 20 additions & 0 deletions lib/cmds/tasks_cmds/retry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const { post } = require('../../api');
const print = require('../../print');
const read = require('../../read');

exports.command = 'retry <taskId>';
exports.desc = 'Retry a task';
exports.builder = yargs => {
yargs.positional('taskId', {
describe: 'The task ID.',
type: 'string'
});
};

exports.handler = async argv => {
const task = await read(argv);
const response = await post(argv, `/v1/tasks/${argv.taskId}:clone`, task);
print(response.data, argv);
};
15 changes: 15 additions & 0 deletions test/unit/commands/task.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const mocks = {

const get = proxyquire('../../../lib/cmds/tasks_cmds/get', mocks);
const cancel = proxyquire('../../../lib/cmds/tasks_cmds/cancel', mocks);
const retry = proxyquire('../../../lib/cmds/tasks_cmds/retry', mocks);
const list = proxyquire('../../../lib/cmds/tasks_cmds/list', mocks);
const create = proxyquire('../../../lib/cmds/tasks_cmds/create', mocks);
const createFoundationTask = proxyquire('../../../lib/cmds/tasks_cmds/create-foundation-task', mocks);
Expand Down Expand Up @@ -299,3 +300,17 @@ test.serial.cb('The "tasks-cancel" command should cancel a task', t => {
yargs.command(cancel)
.parse('cancel taskId');
});

test.serial.cb('The "tasks-retry" command should retry a task', t => {
const res = { data: {} };
postStub.onFirstCall().returns(res);

callback = () => {
t.is(postStub.callCount, 1);
t.is(postStub.getCall(0).args[1], '/v1/tasks/taskId:clone');
t.end();
};

yargs.command(retry)
.parse('retry taskId');
});

0 comments on commit ac3868c

Please sign in to comment.