dir_test.go 687 B

12345678910111213141516171819202122232425262728293031323334
  1. package filesys
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestDirPath(t *testing.T) {
  7. p := &Dir{name: "/some"}
  8. p = &Dir{name: "path", parent: p}
  9. p = &Dir{name: "to", parent: p}
  10. p = &Dir{name: "a", parent: p}
  11. p = &Dir{name: "file", parent: p}
  12. assert.Equal(t, "/some/path/to/a/file", p.FullPath())
  13. p = &Dir{name: "/some"}
  14. assert.Equal(t, "/some", p.FullPath())
  15. p = &Dir{name: "/"}
  16. assert.Equal(t, "/", p.FullPath())
  17. p = &Dir{name: "/"}
  18. p = &Dir{name: "path", parent: p}
  19. assert.Equal(t, "/path", p.FullPath())
  20. p = &Dir{name: "/"}
  21. p = &Dir{name: "path", parent: p}
  22. p = &Dir{name: "to", parent: p}
  23. assert.Equal(t, "/path/to", p.FullPath())
  24. }