mirror of
https://github.com/anchore/syft.git
synced 2025-11-21 02:13:17 +01:00
* add package URL support to the CycloneDX presenter Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * wrap license tags with licenses Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
42 lines
780 B
Go
42 lines
780 B
Go
package pkg
|
|
|
|
import (
|
|
"github.com/sergi/go-diff/diffmatchpatch"
|
|
"testing"
|
|
)
|
|
|
|
func TestJavaMetadata_pURL(t *testing.T) {
|
|
tests := []struct {
|
|
metadata JavaMetadata
|
|
expected string
|
|
}{
|
|
{
|
|
metadata: JavaMetadata{
|
|
PomProperties: &PomProperties{
|
|
Path: "p",
|
|
Name: "n",
|
|
GroupID: "g.id",
|
|
ArtifactID: "a",
|
|
Version: "v",
|
|
},
|
|
},
|
|
expected: "pkg:maven/g.id/a@v",
|
|
},
|
|
{
|
|
metadata: JavaMetadata{},
|
|
expected: "",
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.expected, func(t *testing.T) {
|
|
actual := test.metadata.PackageURL()
|
|
if actual != test.expected {
|
|
dmp := diffmatchpatch.New()
|
|
diffs := dmp.DiffMain(test.expected, actual, true)
|
|
t.Errorf("diff: %s", dmp.DiffPrettyText(diffs))
|
|
}
|
|
})
|
|
}
|
|
}
|