diff --git a/memfs/memory.go b/memfs/memory.go index 978fed1..2641238 100644 --- a/memfs/memory.go +++ b/memfs/memory.go @@ -29,6 +29,7 @@ type Memory struct { // New returns a new Memory filesystem. func New() billy.Filesystem { fs := &Memory{s: newStorage()} + fs.s.New("/", 0755|os.ModeDir, 0) return chroot.New(fs, string(separator)) } diff --git a/memfs/memory_test.go b/memfs/memory_test.go index 26f74ca..030c58a 100644 --- a/memfs/memory_test.go +++ b/memfs/memory_test.go @@ -27,6 +27,12 @@ func (s *MemorySuite) SetUpTest(c *C) { s.FilesystemSuite = test.NewFilesystemSuite(New()) } +func (s *MemorySuite) TestRootExists(c *C) { + f, err := s.FS.Stat("/") + c.Assert(err, IsNil) + c.Assert(f.IsDir(), Equals, true) +} + func (s *MemorySuite) TestCapabilities(c *C) { _, ok := s.FS.(billy.Capable) c.Assert(ok, Equals, true)