fork/gdu
git clone https://git.julia.blue/fork/gdu
da638da
master
1//go:build linux 2 3package remove 4 5import ( 6"os" 7"testing" 8 9"github.com/dundee/gdu/v5/internal/testdir" 10"github.com/dundee/gdu/v5/pkg/analyze" 11"github.com/dundee/gdu/v5/pkg/fs" 12"github.com/stretchr/testify/assert" 13) 14 15func TestItemFromDirParallelWithErr (t * testing.T ) { 16fin := testdir .CreateTestDir () 17defer fin () 18 19err := os .Chmod ("test_dir/nested" ,0 ) 20assert .Nil (t ,err ) 21defer func () { 22err = os .Chmod ("test_dir/nested" ,0o755 ) 23assert .Nil (t ,err ) 24 }() 25 26dir := & analyze.Dir { 27File :& analyze.File { 28Name :"test_dir" , 29 }, 30BasePath :"." , 31 } 32 33subdir := & analyze.Dir { 34File :& analyze.File { 35Name :"nested" , 36Parent :dir , 37 }, 38 } 39 40err = ItemFromDirParallel (dir ,subdir ) 41assert .Contains (t ,err .Error (),"permission denied" ) 42} 43 44func TestItemFromDirParallelWithErr2 (t * testing.T ) { 45fin := testdir .CreateTestDir () 46defer fin () 47 48err := os .Chmod ("test_dir/nested/subnested" ,0 ) 49assert .Nil (t ,err ) 50defer func () { 51err = os .Chmod ("test_dir/nested/subnested" ,0o755 ) 52assert .Nil (t ,err ) 53 }() 54 55analyzer := analyze .CreateAnalyzer () 56dir := analyzer .AnalyzeDir ( 57"test_dir" ,func (_ ,_ string )bool {return false },func (_ string )bool {return false }, 58 ).(* analyze.Dir ) 59analyzer .GetDone ().Wait () 60dir .UpdateStats (make (fs.HardLinkedItems )) 61 62subdir := dir .Files [0 ].(* analyze.Dir ) 63 64err = ItemFromDirParallel (dir ,subdir ) 65assert .Contains (t ,err .Error (),"permission denied" ) 66}