-
Notifications
You must be signed in to change notification settings - Fork 5
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 #14 from lseppala/lsep/purl-qualifiers
Fix encoding of PURL qualifiers
- Loading branch information
Showing
5 changed files
with
58 additions
and
15 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,53 @@ | ||
import ComponentDetection from './componentDetection'; | ||
import fs from 'fs'; | ||
import ComponentDetection from "./componentDetection"; | ||
import fs from "fs"; | ||
|
||
test('Downloads CLI', async () => { | ||
test("Downloads CLI", async () => { | ||
await ComponentDetection.downloadLatestRelease(); | ||
expect(fs.existsSync(ComponentDetection.componentDetectionPath)); | ||
}); | ||
|
||
test('Runs CLI', async () => { | ||
test("Runs CLI", async () => { | ||
await ComponentDetection.downloadLatestRelease(); | ||
await ComponentDetection.runComponentDetection('./test'); | ||
await ComponentDetection.runComponentDetection("./test"); | ||
expect(fs.existsSync(ComponentDetection.outputPath)); | ||
}); | ||
|
||
test('Parses CLI output', async () => { | ||
test("Parses CLI output", async () => { | ||
await ComponentDetection.downloadLatestRelease(); | ||
await ComponentDetection.runComponentDetection('./test'); | ||
await ComponentDetection.runComponentDetection("./test"); | ||
var manifests = await ComponentDetection.getManifestsFromResults(); | ||
expect(manifests?.length == 2); | ||
}); | ||
}); | ||
|
||
describe("ComponentDetection.makePackageUrl", () => { | ||
test("returns a valid package url from saturated object", () => { | ||
const packageUrl = ComponentDetection.makePackageUrl({ | ||
Scheme: "pkg", | ||
Type: "npm", | ||
Namespace: "github", | ||
Name: "component-detection-action", | ||
Version: "0.0.2", | ||
Qualifiers: { | ||
arch: "amd64", | ||
os: "linux", | ||
}, | ||
}); | ||
expect(packageUrl).toBe( | ||
"pkg:npm/github/[email protected]?arch=amd64&os=linux" | ||
); | ||
}); | ||
|
||
test("returns valid package url without dangling ? with empty qualifers", () => { | ||
const packageUrl = ComponentDetection.makePackageUrl({ | ||
Scheme: "pkg", | ||
Type: "npm", | ||
Namespace: "github", | ||
Name: "component-detection-action", | ||
Version: "0.0.2", | ||
Qualifiers: { }, | ||
}); | ||
expect(packageUrl).toBe( | ||
"pkg:npm/github/[email protected]" | ||
); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.