github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/source/source_win_test.go (about) 1 //go:build windows 2 // +build windows 3 4 package source 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func Test_crossPlatformExclusions(t *testing.T) { 13 testCases := []struct { 14 desc string 15 root string 16 path string 17 exclude string 18 match bool 19 }{ 20 { 21 desc: "windows doublestar", 22 root: "C:\\User\\stuff", 23 path: "C:\\User\\stuff\\thing.txt", 24 exclude: "**/*.txt", 25 match: true, 26 }, 27 { 28 desc: "windows relative", 29 root: "C:\\User\\stuff", 30 path: "C:\\User\\stuff\\thing.txt", 31 exclude: "./*.txt", 32 match: true, 33 }, 34 { 35 desc: "windows one level", 36 root: "C:\\User\\stuff", 37 path: "C:\\User\\stuff\\thing.txt", 38 exclude: "*/*.txt", 39 match: false, 40 }, 41 } 42 43 for _, test := range testCases { 44 t.Run(test.desc, func(t *testing.T) { 45 fns, err := getDirectoryExclusionFunctions(test.root, []string{test.exclude}) 46 require.NoError(t, err) 47 48 for _, f := range fns { 49 result := f(test.path, nil) 50 require.Equal(t, test.match, result) 51 } 52 }) 53 } 54 }