Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/interface/cli/commands/workflow/get.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ const command = new Command({
from,
to,
} = argv;
const pipelineNames = !_.isArray(argv['pipeline-name']) ? [(argv['pipeline-name'])] : argv['pipeline-name'];
const pipelineIds = !_.isArray(argv['pipeline-id']) ? [(argv['pipeline-id'])] : argv['pipeline-id'];
const pipelineNames = _.compact(!_.isArray(argv['pipeline-name']) ? [(argv['pipeline-name'])] : argv['pipeline-name']);
const pipelineIds = _.compact(!_.isArray(argv['pipeline-id']) ? [(argv['pipeline-id'])] : argv['pipeline-id']);

const requestOptions = {
limit,
Expand All @@ -140,14 +140,14 @@ const command = new Command({
const pipelines = await sdk.pipelines.list({
id: pipelineNames,
});
if (!_.isEmpty(pipelines)) {
_.forEach(pipelines.docs, (currPipeline) => {
pipelineIds.push(currPipeline.metadata.id);
});
requestOptions.pipeline = pipelineIds;
} else if (_.isEmpty(pipelineIds)) {
const pipelineDocs = _.get(pipelines, 'docs');
if (_.isEmpty(pipelineDocs)) {
throw new CFError('Cannot find any builds with these pipelines names');
}
_.forEach(pipelineDocs, (currPipeline) => {
pipelineIds.push(currPipeline.metadata.id);
});
requestOptions.pipeline = pipelineIds;
} else if (!_.isEmpty(pipelineIds)) {
requestOptions.pipeline = pipelineIds;
}
Expand Down
6 changes: 6 additions & 0 deletions lib/interface/cli/commands/workflow/workflow.sdk.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ describe('workflow commands', () => {
await verifyResponsesReturned(responses); // eslint-disable-line
});

it('should throw when pipeline name does not match any pipeline', async () => {
const argv = { 'pipeline-name': 'does-not-exist' };
request.__setResponse({ statusCode: 200, body: { docs: [] } });
await expect(getCmd.handler(argv)).rejects.toThrow('Cannot find any builds with these pipelines names');
});

it('should handle getting all', async () => {
const argv = { 'pipeline-name': [] };
const response = {
Expand Down