mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 07:56:36 +01:00
35 lines
620 B
Go
35 lines
620 B
Go
package cyclonedxhelpers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func Test_formatCPE(t *testing.T) {
|
|
tests := []struct {
|
|
cpe string
|
|
expected string
|
|
}{
|
|
{
|
|
cpe: "cpe:2.3:o:amazon:amazon_linux:2",
|
|
expected: "cpe:2.3:o:amazon:amazon_linux:2:*:*:*:*:*:*:*",
|
|
},
|
|
{
|
|
cpe: "cpe:/o:opensuse:leap:15.2",
|
|
expected: "cpe:2.3:o:opensuse:leap:15.2:*:*:*:*:*:*:*",
|
|
},
|
|
{
|
|
cpe: "invalid-cpe",
|
|
expected: "",
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.cpe, func(t *testing.T) {
|
|
out := formatCPE(test.cpe)
|
|
assert.Equal(t, test.expected, out)
|
|
})
|
|
}
|
|
}
|