You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
687 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  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. }