Skip to content

Commit

Permalink
feat: PHC-5249 - add get by germline case id command
Browse files Browse the repository at this point in the history
  • Loading branch information
cluebbehusen committed Aug 22, 2023
1 parent 260c643 commit 32a12eb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/cmds/genomics_cmds/ingestions_cmds/get-by-germline-case-id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

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

exports.command = 'get-by-germline-case <projectId> <germlineCaseId>';
exports.desc = 'Fetch ingestion details by <projectId> and <germlineCaseId>';
exports.builder = yargs => {
yargs.positional('projectId', {
describe: 'The project ID.',
type: 'string'
}).positional('germlineCaseId', {
describe: 'The germline case ID.',
type: 'string'
});
};

exports.handler = async argv => {
const response = await get(argv, `/v1/genomic-ingestion/projects/${argv.projectId}/ingestions/germline-cases/${argv.germlineCaseId}`);
print(response.data, argv);
};
15 changes: 15 additions & 0 deletions test/unit/commands/genomics-ingestions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const createCaris = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/
const createFoundationBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-foundation-bam', mocks);
const createCarisBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-caris-bam', mocks);
const createNextGen = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-nextgen', mocks);
const getByGermlineCaseId = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/get-by-germline-case-id', mocks);

test.always.afterEach(t => {
getStub.resetHistory();
Expand Down Expand Up @@ -64,6 +65,20 @@ test.serial.cb('The "list" command should return ingestions based on project id'
yargs.command(list).parse('list projectId -n 1 -t token --name foo --failed false --step Submitted');
});

test.serial.cb('The "get-by-germline-case-id" command should get an ingestion based on project id and germline case id', t => {
const res = { data: { id: 'ingestionId' } };
getStub.onFirstCall().returns(res);
callback = () => {
t.is(getStub.callCount, 1);
t.is(getStub.getCall(0).args[1], '/v1/genomic-ingestion/projects/projectId/ingestions/germline-cases/germlineCaseId');
t.is(printSpy.callCount, 1);
t.true(printSpy.calledWith({ id: 'ingestionId' }));
t.end();
};

yargs.command(getByGermlineCaseId).parse('get-by-germline-case projectId germlineCaseId');
});

test.serial.cb('The "create-foundation" command should create a Foundation ingestion', t => {
const res = { data: { id: 'ingestionId' } };
postStub.onFirstCall().returns(res);
Expand Down

0 comments on commit 32a12eb

Please sign in to comment.