fork/gdu
git clone https://git.julia.blue/fork/gdu
fb46b4f
ignore
1package common_test 2 3import ( 4"os" 5"path/filepath" 6"testing" 7 8"github.com/dundee/gdu/v5/internal/common" 9"github.com/stretchr/testify/assert" 10) 11 12func TestSetIgnoreFromEmptyFile (t * testing.T ) { 13dir := t .TempDir () 14path := filepath .Join (dir ,"ignore" ) 15err := os .WriteFile (path , []byte ("" ),0o600 ) 16assert .Nil (t ,err ) 17 18ui := & common.UI {} 19err = ui .SetIgnoreFromFile (path ) 20assert .Nil (t ,err ) 21 22shouldIgnore := ui .CreateIgnoreFunc () 23assert .False (t ,shouldIgnore ("anything" ,"/anything" )) 24} 25 26func TestSetIgnoreFromFileWithBlankLines (t * testing.T ) { 27dir := t .TempDir () 28path := filepath .Join (dir ,"ignore" ) 29content := "/valid\n/other\n" 30err := os .WriteFile (path , []byte (content ),0o600 ) 31assert .Nil (t ,err ) 32 33ui := & common.UI {} 34err = ui .SetIgnoreFromFile (path ) 35assert .Nil (t ,err ) 36 37shouldIgnore := ui .CreateIgnoreFunc () 38assert .True (t ,shouldIgnore ("valid" ,"/valid" )) 39assert .True (t ,shouldIgnore ("other" ,"/other" )) 40assert .False (t ,shouldIgnore ("xxx" ,"/xxx" )) 41}