lstat_unix_test.go 571 B

123456789101112131415161718192021222324252627282930
  1. // +build linux freebsd
  2. package system
  3. import (
  4. "os"
  5. "testing"
  6. )
  7. // TestLstat tests Lstat for existing and non existing files
  8. func TestLstat(t *testing.T) {
  9. file, invalid, _, dir := prepareFiles(t)
  10. defer os.RemoveAll(dir)
  11. statFile, err := Lstat(file)
  12. if err != nil {
  13. t.Fatal(err)
  14. }
  15. if statFile == nil {
  16. t.Fatal("returned empty stat for existing file")
  17. }
  18. statInvalid, err := Lstat(invalid)
  19. if err == nil {
  20. t.Fatal("did not return error for non-existing file")
  21. }
  22. if statInvalid != nil {
  23. t.Fatal("returned non-nil stat for non-existing file")
  24. }
  25. }