github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/engine/pkg/system/lstat_unix_test.go (about) 1 //go:build linux || freebsd 2 // +build linux freebsd 3 4 package system // import "github.com/docker/docker/pkg/system" 5 6 import ( 7 "os" 8 "testing" 9 ) 10 11 // TestLstat tests Lstat for existing and non existing files 12 func TestLstat(t *testing.T) { 13 file, invalid, _, dir := prepareFiles(t) 14 defer os.RemoveAll(dir) 15 16 statFile, err := Lstat(file) 17 if err != nil { 18 t.Fatal(err) 19 } 20 if statFile == nil { 21 t.Fatal("returned empty stat for existing file") 22 } 23 24 statInvalid, err := Lstat(invalid) 25 if err == nil { 26 t.Fatal("did not return error for non-existing file") 27 } 28 if statInvalid != nil { 29 t.Fatal("returned non-nil stat for non-existing file") 30 } 31 }