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

feat(@snyk/fix): propagate cli test options #1855

Merged
merged 1 commit into from May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/snyk-fix/src/types.ts
Expand Up @@ -185,9 +185,16 @@ export interface EntityToFix {
readonly workspace: Workspace;
readonly scanResult: ScanResult;
readonly testResult: TestResult;
// options
readonly options: CliTestOptions;
}

// Partial CLI test options interface
// defining only what is used by @snyk/fix
// add more as needed
export interface PythonTestOptions {
command?: string; // python interpreter to use for python tests
}
export type CliTestOptions = PythonTestOptions;
export interface WithError<Original> {
original: Original;
error: CustomError;
Expand Down
Expand Up @@ -1243,6 +1243,9 @@ function generateEntityToFix(
testResult: TestResult,
): snykFix.EntityToFix {
const entityToFix = {
options: {
command: 'python3',
},
workspace: {
path: workspacesPath,
readFile: async (path: string) => {
Expand Down
13 changes: 11 additions & 2 deletions packages/snyk-fix/test/helpers/generate-entity-to-fix.ts
@@ -1,5 +1,11 @@
import { DepGraphData } from '@snyk/dep-graph';
import { EntityToFix, ScanResult, TestResult, FixInfo, SEVERITY } from '../../src/types';
import {
EntityToFix,
ScanResult,
TestResult,
FixInfo,
SEVERITY,
} from '../../src/types';

export function generateEntityToFix(
type: string,
Expand All @@ -10,7 +16,10 @@ export function generateEntityToFix(
const scanResult = generateScanResult(type, targetFile);
const testResult = generateTestResult();
const workspace = generateWorkspace(contents, path);
return { scanResult, testResult, workspace };
const cliTestOptions = {
command: 'python3',
};
return { scanResult, testResult, workspace, options: cliTestOptions };
}

function generateWorkspace(contents: string, path?: string) {
Expand Down
15 changes: 15 additions & 0 deletions packages/snyk-fix/test/unit/__snapshots__/fix.spec.ts.snap
Expand Up @@ -6,6 +6,9 @@ Object {
"npm": Object {
"originals": Array [
Object {
"options": Object {
"command": "python3",
},
"scanResult": Object {
"facts": Array [
Object {
Expand Down Expand Up @@ -124,6 +127,9 @@ Summary:
},
],
"original": Object {
"options": Object {
"command": "python3",
},
"scanResult": Object {
"facts": Array [
Object {
Expand Down Expand Up @@ -215,6 +221,9 @@ Re-run in debug mode to see more information: DEBUG=*snyk* <COMMAND>. If the iss
"skipped": Array [
Object {
"original": Object {
"options": Object {
"command": "python3",
},
"scanResult": Object {
"facts": Array [
Object {
Expand Down Expand Up @@ -282,6 +291,9 @@ Re-run in debug mode to see more information: DEBUG=*snyk* <COMMAND>. If the iss
},
],
"original": Object {
"options": Object {
"command": "python3",
},
"scanResult": Object {
"facts": Array [
Object {
Expand Down Expand Up @@ -360,6 +372,9 @@ Object {
},
],
"original": Object {
"options": Object {
"command": "python3",
},
"scanResult": Object {
"facts": Array [
Object {
Expand Down
1 change: 1 addition & 0 deletions src/lib/types.ts
Expand Up @@ -21,6 +21,7 @@ export interface TestOptions {
reachableVulnsTimeout?: number;
initScript?: string;
yarnWorkspaces?: boolean;
command?: string; // python interpreter to use for python tests
testDepGraphDockerEndpoint?: string | null;
isDockerUser?: boolean;
/** @deprecated Only used by the legacy `iac test` flow remove once local exec path is GA */
Expand Down