mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
add unit tests for distro identification based on "like" field
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
c833472b6e
commit
32a54b94be
@ -97,8 +97,7 @@ func assemble(name, version, like string) *Distro {
|
|||||||
|
|
||||||
// If it's an unknown distro, try mapping the ID_LIKE
|
// If it's an unknown distro, try mapping the ID_LIKE
|
||||||
if !ok && len(like) != 0 {
|
if !ok && len(like) != 0 {
|
||||||
name = like
|
distroType, ok = IDMapping[like]
|
||||||
distroType, ok = IDMapping[name]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
|
|||||||
@ -7,9 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal"
|
"github.com/anchore/syft/internal"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
|
|
||||||
"github.com/anchore/syft/syft/source"
|
"github.com/anchore/syft/syft/source"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIdentifyDistro(t *testing.T) {
|
func TestIdentifyDistro(t *testing.T) {
|
||||||
@ -85,6 +84,20 @@ func TestIdentifyDistro(t *testing.T) {
|
|||||||
fixture: "test-fixtures/os/arch",
|
fixture: "test-fixtures/os/arch",
|
||||||
Type: ArchLinux,
|
Type: ArchLinux,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/partial-fields/missing-id",
|
||||||
|
Type: Debian,
|
||||||
|
Version: "8.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/partial-fields/unknown-id",
|
||||||
|
Type: Debian,
|
||||||
|
Version: "8.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/partial-fields/missing-version",
|
||||||
|
Type: UnknownDistroType,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
observedDistros := internal.NewStringSet()
|
observedDistros := internal.NewStringSet()
|
||||||
|
|||||||
@ -0,0 +1,3 @@
|
|||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
VERSION_ID="8"
|
||||||
|
ID_LIKE=debian
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
ID_LIKE=debian
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
NAME="Debian GNU/Linux"
|
||||||
|
VERSION_ID="8"
|
||||||
|
ID=my-awesome-distro
|
||||||
|
ID_LIKE=debian
|
||||||
Loading…
x
Reference in New Issue
Block a user