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