Skip to content

Commit 3ce9d43

Browse files
committed
test: test that we can open a lot of temp files
1 parent c329b7b commit 3ce9d43

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/tempfile.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
. "gopkg.in/check.v1"
77
"gopkg.in/src-d/go-billy.v3"
8+
"gopkg.in/src-d/go-billy.v3/util"
89
)
910

1011
// TempFileSuite is a convenient test suite to validate any implementation of
@@ -49,3 +50,37 @@ func (s *TempFileSuite) TestRemoveTempFile(c *C) {
4950
c.Assert(f.Close(), IsNil)
5051
c.Assert(s.FS.Remove(fn), IsNil)
5152
}
53+
54+
func (s *TempFileSuite) TestTempFileMany(c *C) {
55+
for i := 0; i < 1024; i++ {
56+
var fs []billy.File
57+
58+
for j := 0; j < 100; j++ {
59+
f, err := s.FS.TempFile("test-dir", "test-prefix")
60+
c.Assert(err, IsNil)
61+
fs = append(fs, f)
62+
}
63+
64+
for _, f := range fs {
65+
c.Assert(f.Close(), IsNil)
66+
c.Assert(s.FS.Remove(f.Name()), IsNil)
67+
}
68+
}
69+
}
70+
71+
func (s *TempFileSuite) TestTempFileManyWithUtil(c *C) {
72+
for i := 0; i < 1024; i++ {
73+
var fs []billy.File
74+
75+
for j := 0; j < 100; j++ {
76+
f, err := util.TempFile(s.FS, "test-dir", "test-prefix")
77+
c.Assert(err, IsNil)
78+
fs = append(fs, f)
79+
}
80+
81+
for _, f := range fs {
82+
c.Assert(f.Close(), IsNil)
83+
c.Assert(s.FS.Remove(f.Name()), IsNil)
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)