Skip to content

Commit

Permalink
Bail out with an error, if non-existent entry point is provided
Browse files Browse the repository at this point in the history
For lookupStrategy "multipleIdOrName", we should bail out wit an error
if one of the provided entrypoints does not exist.
  • Loading branch information
Raman Aleksandrovich committed Aug 10, 2021
1 parent 09e11bc commit 98fb5b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/runner/extract-runnable-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ var sdk = require('postman-collection'),
// at this point of time, we should have traversed all items mentioned in entrypoint and created a linear
// subset of items. However, if post that, we still have items remaining in lookup object, that implies that
// extra items were present in user input and corresponding items for those do not exist in collection. As such
// we need to bail out if any of the given entry-point is not found.
// we need to bail out with an error if any of the given entry-point is not found.
if (Object.keys(entrypointLookup).length) {
return callback(null, []);
return callback(new Error('Unable to find an entry point'));
}

// extract runnable items from the searched items.
Expand Down
12 changes: 7 additions & 5 deletions test/unit/extract-runnable-items.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,18 @@ describe('extractRunnableItems', function () {
);
});

it('should bail out if any of the given entrypoint is not found. ', function (done) {
it('should throw an error if non-existent entry points were provided', function (done) {
extractRunnableItems(
collection, {
execute: ['ID3', 'RANDOM'],
lookupStrategy: 'multipleIdOrName'
execute: ['RANDOM', 'F1.R1', 'F2.R1'],
lookupStrategy: 'multipleIdOrName',
abortOnError: true
},
function (err, runnableItems, entrypoint) {
expect(err).to.be.null;
expect(runnableItems).to.eql([]);
expect(err.message).to.equal('Unable to find an entry point');
expect(runnableItems).to.be.undefined;
expect(entrypoint).to.be.undefined;

done();
}
);
Expand Down

0 comments on commit 98fb5b2

Please sign in to comment.