From bcb92c61aebc212b6d7acbaf5e26a19571ef0060 Mon Sep 17 00:00:00 2001 From: ghe Date: Tue, 16 Jun 2020 14:42:09 +0100 Subject: [PATCH 1/2] fix:ensure-logging-path-set --- src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.ts b/src/index.ts index e4d281b5..d12f86fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,8 +6,10 @@ const debug = debugLib('snyk:import-projects-script'); export * from './lib'; import { ImportProjects } from './scripts/import-projects'; import { getImportProjectsFile } from './lib/get-import-path'; +import { getLoggingPath } from './lib/get-logging-path'; try { + getLoggingPath() const importFile = getImportProjectsFile(); ImportProjects(importFile); } catch (e) { From 426789a90020697160e5b1acebc490130caae2c0 Mon Sep 17 00:00:00 2001 From: ghe Date: Tue, 16 Jun 2020 14:42:37 +0100 Subject: [PATCH 2/2] fix: reduce poll interval from 30s to 20s --- src/lib/poll-import/index.ts | 2 +- test/lib/index.test.ts | 2 +- test/scripts/import-projects.test.ts | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib/poll-import/index.ts b/src/lib/poll-import/index.ts index a81ef4dd..d4a0b8b1 100644 --- a/src/lib/poll-import/index.ts +++ b/src/lib/poll-import/index.ts @@ -11,7 +11,7 @@ import { logFailedPollUrls } from '../../log-failed-polls'; import { logImportedProjects } from '../../log-imported-projects'; const debug = debugLib('snyk:poll-import'); -const MIN_RETRY_WAIT_TIME = 30000; +const MIN_RETRY_WAIT_TIME = 20000; const MAX_RETRY_COUNT = 1000; export async function pollImportUrl( diff --git a/test/lib/index.test.ts b/test/lib/index.test.ts index cd92f232..c7b0d4b4 100644 --- a/test/lib/index.test.ts +++ b/test/lib/index.test.ts @@ -58,7 +58,7 @@ describe('Multiple targets', () => { process.env.SNYK_API = SNYK_API_TEST; process.env.SNYK_TOKEN = process.env.SNYK_TOKEN_TEST; - it('importTargets & pollImportUrls multiple repos', async () => { + it('importTargets & pollImportUrls multiple repos', async () => { logs = Object.values(generateLogsPaths(__dirname, ORG_ID)); const pollingUrls = await importTargets([ { diff --git a/test/scripts/import-projects.test.ts b/test/scripts/import-projects.test.ts index bca3279f..77e1a77f 100644 --- a/test/scripts/import-projects.test.ts +++ b/test/scripts/import-projects.test.ts @@ -190,6 +190,18 @@ describe('Error handling', () => { ), ).rejects.toThrow('Failed to parse targets from'); }, 300); + + it('shows correct error when SNYK_LOG_PATH is not set', async () => { + delete process.env.SNYK_LOG_PATH; + expect( + ImportProjects( + path.resolve( + __dirname + + '/fixtures/invalid-target/import-projects-invalid-target.json', + ), + ), + ).rejects.toThrow('Please set the SNYK_LOG_PATH e.g. export SNYK_LOG_PATH'); + }, 300); }); describe('Polling', () => {