From 98fb5b2fce9768c14461588fb8bdd8c48da0d685 Mon Sep 17 00:00:00 2001 From: Raman Aleksandrovich Date: Sat, 7 Aug 2021 12:49:44 +0300 Subject: [PATCH] Bail out with an error, if non-existent entry point is provided For lookupStrategy "multipleIdOrName", we should bail out wit an error if one of the provided entrypoints does not exist. --- lib/runner/extract-runnable-items.js | 4 ++-- test/unit/extract-runnable-items.test.js | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/runner/extract-runnable-items.js b/lib/runner/extract-runnable-items.js index f15bd52f7..efe580802 100644 --- a/lib/runner/extract-runnable-items.js +++ b/lib/runner/extract-runnable-items.js @@ -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. diff --git a/test/unit/extract-runnable-items.test.js b/test/unit/extract-runnable-items.test.js index 1baab5365..ca234958b 100644 --- a/test/unit/extract-runnable-items.test.js +++ b/test/unit/extract-runnable-items.test.js @@ -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(); } );