aboutsummaryrefslogtreecommitdiffstats
path: root/utils/fs/test
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-20 11:30:01 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-20 11:30:01 +0100
commit2e60c554dbe56eed3e9a503d03fed01b459d029a (patch)
tree47ef669288c73147f1d0992912f8228828d3d5b4 /utils/fs/test
parent16d86605732ba3198c0acd4317b53cf4991a7d4d (diff)
downloadgo-git-2e60c554dbe56eed3e9a503d03fed01b459d029a.tar.gz
utils: fs, memory fix ReadDir, error getting filename
Diffstat (limited to 'utils/fs/test')
-rw-r--r--utils/fs/test/fs_suite.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/utils/fs/test/fs_suite.go b/utils/fs/test/fs_suite.go
index 5aa99e6..01d6112 100644
--- a/utils/fs/test/fs_suite.go
+++ b/utils/fs/test/fs_suite.go
@@ -256,6 +256,48 @@ func (s *FilesystemSuite) TestReadDirAndDir(c *C) {
c.Assert(info, HasLen, 2)
}
+func (s *FilesystemSuite) TestReadDirFileInfo(c *C) {
+ f, err := s.Fs.Create("foo")
+ c.Assert(err, IsNil)
+ n, err := f.Write([]byte{'F', 'O', 'O'})
+ c.Assert(n, Equals, 3)
+ c.Assert(err, IsNil)
+ c.Assert(f.Close(), IsNil)
+
+ info, err := s.Fs.ReadDir("/")
+ c.Assert(err, IsNil)
+ c.Assert(info, HasLen, 1)
+
+ c.Assert(info[0].Size(), Equals, int64(3))
+ c.Assert(info[0].IsDir(), Equals, false)
+ c.Assert(info[0].Name(), Equals, "foo")
+}
+
+func (s *FilesystemSuite) TestReadDirFileInfoDirs(c *C) {
+ files := []string{"qux/baz/foo"}
+ for _, name := range files {
+ f, err := s.Fs.Create(name)
+ c.Assert(err, IsNil)
+ n, err := f.Write([]byte{'F', 'O', 'O'})
+ c.Assert(n, Equals, 3)
+ c.Assert(err, IsNil)
+ c.Assert(f.Close(), IsNil)
+ }
+
+ info, err := s.Fs.ReadDir("qux")
+ c.Assert(err, IsNil)
+ c.Assert(info, HasLen, 1)
+ c.Assert(info[0].IsDir(), Equals, true)
+ c.Assert(info[0].Name(), Equals, "baz")
+
+ info, err = s.Fs.ReadDir("qux/baz")
+ c.Assert(err, IsNil)
+ c.Assert(info, HasLen, 1)
+ c.Assert(info[0].Size(), Equals, int64(3))
+ c.Assert(info[0].IsDir(), Equals, false)
+ c.Assert(info[0].Name(), Equals, "foo")
+}
+
func (s *FilesystemSuite) TestDirStat(c *C) {
files := []string{"foo", "bar", "qux/baz", "qux/qux"}
for _, name := range files {