Skip to content

Commit

Permalink
Merge pull request #51 from snyk-tech-services/fix/ensure-logging-pat…
Browse files Browse the repository at this point in the history
…h-set

Fix/ensure logging path set
  • Loading branch information
lili2311 authored Jun 16, 2020
2 parents c8266ec + 426789a commit d89fe18
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/poll-import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/lib/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down
12 changes: 12 additions & 0 deletions test/scripts/import-projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit d89fe18

Please sign in to comment.