Skip to content

Commit

Permalink
fix: allow tests to be run against any snyk API
Browse files Browse the repository at this point in the history
  • Loading branch information
gitphill committed Jan 8, 2020
1 parent 3b6e939 commit 878f5a9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/policy-display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { test } from 'tap';
import * as fs from 'then-fs';
import { display } from '../src/lib/display-policy';
import stripAnsi from 'strip-ansi';
import { URL } from 'url';

const SNYK_API = process.env.SNYK_API || 'https://snyk.io/api/v1';
const { hostname } = new URL(SNYK_API);

test('test sensibly bails if gets an old .snyk format', async (t) => {
const filename = __dirname + '/fixtures/snyk-config-no-version';
Expand All @@ -21,6 +25,8 @@ test('test sensibly bails if gets an old .snyk format', async (t) => {
.join('\n');
const expected = expectedFileString
.trim()
// replace hostname in policy if using env var SNYK_API
.replace(/snyk\.io/g, hostname)
.split('\n')
.slice(3)
.join('\n');
Expand Down

0 comments on commit 878f5a9

Please sign in to comment.