-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1297 from snyk/fix/protect-shouldnt-fail-when-the…
…res-nothing-to-do fix: protect will not fail when there are not vulns to patch
- Loading branch information
Showing
3 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { test } from 'tap'; | ||
import * as cli from '../../src/cli/commands'; | ||
import * as sinon from 'sinon'; | ||
import * as snyk from '../../src/lib'; | ||
|
||
test('`protect` with no vulns to patch', async (t) => { | ||
t.plan(1); | ||
const vulns = require('./fixtures/npm-package/test-graph-result.json'); | ||
vulns.vulnerabilities = undefined; | ||
const testStub = sinon.stub(snyk, 'test').returns(vulns); | ||
|
||
try { | ||
const result = await cli.protect(); | ||
t.match(result, 'Code is already patched, nothing to do'); | ||
} catch (err) { | ||
t.fail('should not fail'); | ||
} finally { | ||
testStub.restore(); | ||
} | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters