mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 16:06:36 +01:00
Signed-off-by: Avi Deitcher <avi@deitcher.net> Co-authored-by: Keith Zantow <kzantow@gmail.com>
59 lines
1.2 KiB
Go
59 lines
1.2 KiB
Go
package golang
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
|
|
)
|
|
|
|
func Test_Mod_Cataloger_Globs(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
fixture string
|
|
expected []string
|
|
}{
|
|
{
|
|
name: "obtain go.mod files",
|
|
fixture: "test-fixtures/glob-paths",
|
|
expected: []string{
|
|
"src/go.mod",
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
pkgtest.NewCatalogTester().
|
|
FromDirectory(t, test.fixture).
|
|
ExpectsResolverContentQueries(test.expected).
|
|
IgnoreUnfulfilledPathResponses("src/go.sum").
|
|
TestCataloger(t, NewGoModFileCataloger(GoCatalogerOpts{}))
|
|
})
|
|
}
|
|
}
|
|
|
|
func Test_Binary_Cataloger_Globs(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
fixture string
|
|
expected []string
|
|
}{
|
|
{
|
|
name: "obtain binary files",
|
|
fixture: "test-fixtures/glob-paths",
|
|
expected: []string{
|
|
"partial-binary",
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
pkgtest.NewCatalogTester().
|
|
FromDirectory(t, test.fixture).
|
|
ExpectsResolverContentQueries(test.expected).
|
|
TestCataloger(t, NewGoModuleBinaryCataloger(GoCatalogerOpts{}))
|
|
})
|
|
}
|
|
}
|