Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow tests to be run against any snyk API #951

Merged
merged 1 commit into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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