syft/syft/pkg/cataloger/golang/subfs_test.go
Avi Deitcher b69259534d
feat: Support scanning license files in golang packages over the network (#1630)
Signed-off-by: Avi Deitcher <avi@deitcher.net>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Co-authored-by: Keith Zantow <kzantow@gmail.com>
Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
2023-04-14 15:13:29 -04:00

28 lines
508 B
Go

package golang
import (
"io/fs"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func Test_NewSubFS(t *testing.T) {
f := os.DirFS("test-fixtures/zip-fs")
f = newSubFS(f, "github.com/someorg/somepkg@version")
var names []string
err := fs.WalkDir(f, ".", func(path string, d fs.DirEntry, err error) error {
names = append(names, path)
return nil
})
require.NoError(t, err)
expected := []string{
".",
"a-file",
"subdir",
"subdir/subfile",
}
require.Equal(t, expected, names)
}