Skip to content

Commit d0dc16d

Browse files
authored
Merge pull request #43 from smola/nested-dirs
test: add test for highly nested directories
2 parents 4ad7906 + f20ea4c commit d0dc16d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/dir.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package test
22

33
import (
44
"os"
5+
"strconv"
56

67
. "gopkg.in/check.v1"
78
. "gopkg.in/src-d/go-billy.v3"
@@ -135,6 +136,33 @@ func (s *DirSuite) TestReadDir(c *C) {
135136
c.Assert(info, HasLen, 2)
136137
}
137138

139+
func (s *DirSuite) TestReadDirNested(c *C) {
140+
max := 100
141+
path := "/"
142+
for i := 0; i <= max; i++ {
143+
path = s.FS.Join(path, strconv.Itoa(i))
144+
}
145+
146+
files := []string{s.FS.Join(path, "f1"), s.FS.Join(path, "f2")}
147+
for _, name := range files {
148+
err := util.WriteFile(s.FS, name, nil, 0644)
149+
c.Assert(err, IsNil)
150+
}
151+
152+
path = "/"
153+
for i := 0; i < max; i++ {
154+
path = s.FS.Join(path, strconv.Itoa(i))
155+
info, err := s.FS.ReadDir(path)
156+
c.Assert(err, IsNil)
157+
c.Assert(info, HasLen, 1)
158+
}
159+
160+
path = s.FS.Join(path, strconv.Itoa(max))
161+
info, err := s.FS.ReadDir(path)
162+
c.Assert(err, IsNil)
163+
c.Assert(info, HasLen, 2)
164+
}
165+
138166
func (s *DirSuite) TestReadDirWithMkDirAll(c *C) {
139167
err := s.FS.MkdirAll("qux", 0644)
140168
c.Assert(err, IsNil)

0 commit comments

Comments
 (0)