From 70f8094bec321ee8c671688feed6114597ad5f1e Mon Sep 17 00:00:00 2001 From: Federico Builes Date: Wed, 31 May 2023 16:24:19 +0200 Subject: [PATCH] adding a test for empty PURLs --- __tests__/licenses.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/__tests__/licenses.test.ts b/__tests__/licenses.test.ts index ae9f3f0b3..5cd5c0c6d 100644 --- a/__tests__/licenses.test.ts +++ b/__tests__/licenses.test.ts @@ -192,6 +192,23 @@ test('it does not filter out changes that are on the exclusions list', async () expect(invalidLicenses.forbidden.length).toEqual(0) }) +test('it does not fail when the packages dont have a valid PURL', async () => { + const emptyPurlChange = pipChange + emptyPurlChange.package_url = '' + + const changes: Changes = [emptyPurlChange, npmChange, rubyChange] + const licensesConfig = { + allow: ['BSD'], + licenseExclusions: ['pkg:pip/package-1@1.1.1', 'pkg:npm/reeuhq@1.0.2'] + } + + const invalidLicenses = await getInvalidLicenseChanges( + changes, + licensesConfig + ) + expect(invalidLicenses.forbidden.length).toEqual(1) +}) + test('it does filters out changes if they are not on the exclusions list', async () => { const changes: Changes = [pipChange, npmChange, rubyChange] const licensesConfig = {