-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(packagejson): move logic to find files from Trivy
- Loading branch information
1 parent
fd92745
commit 757ba41
Showing
4 changed files
with
78 additions
and
7 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
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ package packagejson_test | |
|
||
import ( | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
@@ -34,7 +33,7 @@ func TestParse(t *testing.T) { | |
Version: "5.0.2", | ||
Licenses: types.Licenses{ | ||
{ | ||
Type: types.NameLicenseType, | ||
Type: types.LicenseTypeName, | ||
Value: "MIT", | ||
}, | ||
}, | ||
|
@@ -65,7 +64,7 @@ func TestParse(t *testing.T) { | |
Version: "4.1.2", | ||
Licenses: types.Licenses{ | ||
{ | ||
Type: types.NameLicenseType, | ||
Type: types.LicenseTypeName, | ||
Value: "ISC", | ||
}, | ||
}, | ||
|
@@ -84,6 +83,46 @@ func TestParse(t *testing.T) { | |
Library: types.Library{ | ||
ID: "", | ||
Name: "angular", | ||
Licenses: types.Licenses{ | ||
{ | ||
Type: types.LicenseTypeFile, | ||
Value: "LICENSE", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "happy path - licenseRef is used", | ||
inputFile: "testdata/license-ref.json", | ||
want: packagejson.Package{ | ||
Library: types.Library{ | ||
ID: "[email protected]", | ||
Name: "package-b", | ||
Version: "0.0.1", | ||
Licenses: types.Licenses{ | ||
{ | ||
Type: types.LicenseTypeFile, | ||
Value: "LICENSE.txt", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "happy path - 'SEE LICENSE IN` is used", | ||
inputFile: "testdata/see-license.json", | ||
want: packagejson.Package{ | ||
Library: types.Library{ | ||
ID: "[email protected]", | ||
Name: "package-c", | ||
Version: "0.0.1", | ||
Licenses: types.Licenses{ | ||
{ | ||
Type: types.LicenseTypeFile, | ||
Value: "LICENSE.md", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -104,7 +143,7 @@ func TestParse(t *testing.T) { | |
Library: types.Library{ | ||
Licenses: types.Licenses{ | ||
{ | ||
Type: types.NameLicenseType, | ||
Type: types.LicenseTypeName, | ||
Value: "MIT", | ||
}, | ||
}, | ||
|
@@ -114,7 +153,7 @@ func TestParse(t *testing.T) { | |
} | ||
|
||
for _, v := range vectors { | ||
t.Run(path.Base(v.name), func(t *testing.T) { | ||
t.Run(v.name, func(t *testing.T) { | ||
f, err := os.Open(v.inputFile) | ||
require.NoError(t, err) | ||
defer f.Close() | ||
|
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,5 @@ | ||
{ | ||
"name": "package-b", | ||
"version": "0.0.1", | ||
"license": "LicenseRef-LICENSE.txt" | ||
} |
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,5 @@ | ||
{ | ||
"name": "package-c", | ||
"version": "0.0.1", | ||
"license": "SEE LICENSE IN LICENSE.md" | ||
} |