mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
* [CycloneDX] Add artifactID and groupID to the cycloneDX properties Signed-off-by: Peter Balogh <p.balogh.sa@gmail.com> * update comment Signed-off-by: Peter Balogh <p.balogh.sa@gmail.com> * additional checks for value Signed-off-by: Peter Balogh <p.balogh.sa@gmail.com> * fill group filed with groupID in the case of Java Signed-off-by: Peter Balogh <p.balogh.sa@gmail.com> * fix linter warning Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
53 lines
960 B
Go
53 lines
960 B
Go
package cyclonedxhelpers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/syft/pkg"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGroup(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
input pkg.Package
|
|
expected string
|
|
}{
|
|
{
|
|
name: "no metadata",
|
|
input: pkg.Package{},
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "metadata is not Java",
|
|
input: pkg.Package{
|
|
Metadata: pkg.NpmPackageJSONMetadata{},
|
|
},
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "metadata is Java but pom properties is empty",
|
|
input: pkg.Package{
|
|
Metadata: pkg.JavaMetadata{},
|
|
},
|
|
expected: "",
|
|
},
|
|
{
|
|
name: "metadata is Java and contains pomProperties",
|
|
input: pkg.Package{
|
|
Metadata: pkg.JavaMetadata{
|
|
PomProperties: &pkg.PomProperties{
|
|
GroupID: "test",
|
|
},
|
|
},
|
|
},
|
|
expected: "test",
|
|
},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
assert.Equal(t, test.expected, Group(test.input))
|
|
})
|
|
}
|
|
}
|