From f3ab3a6c73015b5ae9b2a4756dc646e1211cedb9 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Wed, 26 Oct 2016 17:53:19 +0200 Subject: utils/fs/test: add testing of stat on subdirs. (#99) * Some 3rd party implementations had bugs on this that went unnoticed. --- utils/fs/test/fs_suite.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'utils/fs/test') diff --git a/utils/fs/test/fs_suite.go b/utils/fs/test/fs_suite.go index e8e04ab..a809309 100644 --- a/utils/fs/test/fs_suite.go +++ b/utils/fs/test/fs_suite.go @@ -95,6 +95,24 @@ func (s *FilesystemSuite) TestReadDirAndDir(c *C) { c.Assert(info, HasLen, 2) } +func (s *FilesystemSuite) TestDirStat(c *C) { + files := []string{"foo", "bar", "qux/baz", "qux/qux"} + for _, name := range files { + f, err := s.Fs.Create(name) + c.Assert(err, IsNil) + c.Assert(f.Close(), IsNil) + } + + qux := s.Fs.Dir("qux") + fi, err := qux.Stat("baz") + c.Assert(err, IsNil) + c.Assert(fi.Name(), Equals, "baz") + + fi, err = qux.Stat("/baz") + c.Assert(err, IsNil) + c.Assert(fi.Name(), Equals, "baz") +} + func (s *FilesystemSuite) TestCreateInDir(c *C) { dir := s.Fs.Dir("foo") f, err := dir.Create("bar") -- cgit