fork/gdu
git clone https://git.julia.blue/fork/gdu
d062e88
ignore
1//go:build linux 2 3package report 4 5import ( 6"bytes" 7"os" 8"testing" 9 10"github.com/dundee/gdu/v5/internal/testdir" 11"github.com/dundee/gdu/v5/pkg/analyze" 12"github.com/stretchr/testify/assert" 13) 14 15func TestReadFromStorage (t * testing.T ) { 16fin := testdir .CreateTestDir () 17defer fin () 18 19const storagePath = "/tmp/badger-test2" 20defer func () { 21err := os .RemoveAll (storagePath ) 22if err != nil { 23panic (err ) 24 } 25 }() 26 27output := bytes .NewBuffer (make ([]byte ,10 )) 28reportOutput := bytes .NewBuffer (make ([]byte ,10 )) 29 30ui := CreateExportUI (output ,reportOutput ,false ,true ,false ,0 ,0 ,false ,nil ) 31ui .SetIgnoreDirPaths ([]string {"/xxx" }) 32ui .SetAnalyzer (analyze .CreateStoredAnalyzer (storagePath )) 33err := ui .AnalyzePath ("test_dir" ,nil ) 34assert .Nil (t ,err ) 35err = ui .ReadFromStorage (storagePath ,"test_dir" ) 36 37assert .Nil (t ,err ) 38assert .Contains (t ,reportOutput .String (),`"name":"nested"` ) 39} 40 41func TestReadFromStorageWithErr (t * testing.T ) { 42fin := testdir .CreateTestDir () 43defer fin () 44 45const storagePath = "/tmp/badger-test3" 46 47output := bytes .NewBuffer (make ([]byte ,10 )) 48reportOutput := bytes .NewBuffer (make ([]byte ,10 )) 49 50ui := CreateExportUI (output ,reportOutput ,false ,false ,false ,0 ,0 ,false ,nil ) 51ui .SetIgnoreDirPaths ([]string {"/xxx" }) 52err := ui .ReadFromStorage (storagePath ,"test_dir" ) 53 54assert .ErrorContains (t ,err ,"Key not found" ) 55}