-
Notifications
You must be signed in to change notification settings - Fork 12
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 #102 from snyk/feat/legacy-purl
feat: add purl to legacy dep tree
- Loading branch information
Showing
2 changed files
with
49 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 |
---|---|---|
|
@@ -260,6 +260,46 @@ describe('depTreeToGraph with funky pipes in the version', () => { | |
}); | ||
}); | ||
|
||
describe('depTreeToGraph with purl', () => { | ||
const depTree = { | ||
name: 'oak', | ||
version: '1.0', | ||
purl: 'pkg:deb/[email protected]', | ||
dependencies: { | ||
foo: { | ||
version: 'v2.3.0', | ||
purl: 'pkg:deb/[email protected]', | ||
}, | ||
bar: { | ||
version: '1', | ||
purl: 'pkg:dep/bar@1', | ||
dependencies: { | ||
foo: { | ||
version: 'v2.4.0', | ||
purl: 'pkg:deb/[email protected]', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
let depGraph: types.DepGraph; | ||
test('create', async () => { | ||
depGraph = await depGraphLib.legacy.depTreeToGraph(depTree, 'deb'); | ||
expect(depGraph.getPkgs()).toHaveLength(4); | ||
expect(depGraph.getDepPkgs()).toHaveLength(3); | ||
depGraph.getPkgs().forEach((pkg) => expect(pkg.purl).toBeDefined()); | ||
}); | ||
|
||
test('convert to JSON and back', async () => { | ||
const graphJson = depGraph.toJSON(); | ||
const restoredGraph = await depGraphLib.createFromJSON(graphJson); | ||
|
||
helpers.expectSamePkgs(restoredGraph.getPkgs(), depGraph.getPkgs()); | ||
helpers.expectSamePkgs(restoredGraph.getDepPkgs(), depGraph.getDepPkgs()); | ||
}); | ||
}); | ||
|
||
describe('depTreeToGraph cycle with root', () => { | ||
const depTree = { | ||
name: 'maple', | ||
|