From 1b3df2dcdcd3aefe05c989783680fa059ebeccd1 Mon Sep 17 00:00:00 2001 From: Connor Luebbehusen Date: Wed, 30 Aug 2023 07:39:20 -0400 Subject: [PATCH] feat: PHC-5229 - add vcf ingest command --- .../ingestions_cmds/create-vcf.js | 40 +++++++++++++++++++ .../unit/commands/genomics-ingestions.test.js | 26 ++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 lib/cmds/genomics_cmds/ingestions_cmds/create-vcf.js diff --git a/lib/cmds/genomics_cmds/ingestions_cmds/create-vcf.js b/lib/cmds/genomics_cmds/ingestions_cmds/create-vcf.js new file mode 100644 index 0000000..95166ff --- /dev/null +++ b/lib/cmds/genomics_cmds/ingestions_cmds/create-vcf.js @@ -0,0 +1,40 @@ +'use strict'; + +const { post } = require('../../../api'); +const print = require('../../../print'); + +exports.command = 'create-vcf '; +exports.desc = 'Create VCF ingestion for and in '; +exports.builder = yargs => { + yargs.positional('projectId', { + describe: 'The project ID.', + type: 'string' + }).positional('vcfFileId', { + describe: 'The ID of the VCF file.', + type: 'string' + }).positional('manifestFileId', { + describe: 'The ID of the manifest file.', + type: 'string' + }).option('succeededEmail', { + describe: 'An email address to notify if the ingestion succeeds', + type: 'string' + }).option('failedEmail', { + describe: 'An email address to notify if the ingestion fails', + type: 'string' + }); +}; + +exports.handler = async argv => { + const response = await post(argv, `/v1/genomic-ingestion/projects/${argv.projectId}/ingestions`, { + ingestionType: 'Vcf', + inputFiles: { + vcf: argv.vcfFileId, + manifest: argv.manifestFileId + }, + notificationConfig: { + succeededEmail: argv.succeededEmail, + failedEmail: argv.failedEmail + } + }); + print(response.data, argv); +}; diff --git a/test/unit/commands/genomics-ingestions.test.js b/test/unit/commands/genomics-ingestions.test.js index 3059286..b255b44 100644 --- a/test/unit/commands/genomics-ingestions.test.js +++ b/test/unit/commands/genomics-ingestions.test.js @@ -29,6 +29,7 @@ const createFoundationBam = proxyquire('../../../lib/cmds/genomics_cmds/ingestio 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); +const createVcf = proxyquire('../../../lib/cmds/genomics_cmds/ingestions_cmds/create-vcf', mocks); test.always.afterEach(t => { getStub.resetHistory(); @@ -200,3 +201,28 @@ test.serial.cb('The "create-nextgen" command should create a NextGen ingestion', yargs.command(createNextGen).parse('create-nextgen projectId tarFileId'); }); + +test.serial.cb('The "create-vcf" command should create a VCF ingestion', t => { + const res = { data: { id: 'ingestionId' } }; + postStub.onFirstCall().returns(res); + callback = () => { + t.is(postStub.callCount, 1); + t.is(postStub.getCall(0).args[1], '/v1/genomic-ingestion/projects/projectId/ingestions'); + t.deepEqual(postStub.getCall(0).args[2], { + ingestionType: 'Vcf', + inputFiles: { + vcf: 'vcfFileId', + manifest: 'manifestFileId' + }, + notificationConfig: { + succeededEmail: 'test@testing.com', + failedEmail: 'test@testing.com' + } + }); + t.is(printSpy.callCount, 1); + t.true(printSpy.calledWith({ id: 'ingestionId' })); + t.end(); + }; + + yargs.command(createVcf).parse('create-vcf projectId vcfFileId manifestFileId --succeededEmail test@testing.com --failedEmail test@testing.com'); +});