github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/golang/subfs_test.go (about)

     1  package golang
     2  
     3  import (
     4  	"io/fs"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/require"
     9  )
    10  
    11  func Test_NewSubFS(t *testing.T) {
    12  	f := os.DirFS("test-fixtures/zip-fs")
    13  	f = newSubFS(f, "github.com/someorg/somepkg@version")
    14  	var names []string
    15  	err := fs.WalkDir(f, ".", func(path string, d fs.DirEntry, err error) error {
    16  		names = append(names, path)
    17  		return nil
    18  	})
    19  	require.NoError(t, err)
    20  	expected := []string{
    21  		".",
    22  		"a-file",
    23  		"subdir",
    24  		"subdir/subfile",
    25  	}
    26  	require.Equal(t, expected, names)
    27  }