From 171091926d3836c642e22c346494806463e2fdb7 Mon Sep 17 00:00:00 2001 From: Martin Bertschler Date: Wed, 4 Nov 2015 23:43:06 +0100 Subject: [PATCH] change Readdir test to work, update Fs and File interface in README Readdir test worked on OS X but not on CI, because the assumption that the os.File Readdir returns files sorted by name is not true on all operating systems --- README.md | 20 +++++++++++++++++++- fs_test.go | 6 ++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 256dffe..4caed92 100644 --- a/README.md +++ b/README.md @@ -100,8 +100,10 @@ the ability to drop in other filesystems as desired. Then throughout your functions and methods use the methods familiar already from the OS package. -Methods Available: +File System Methods Available: + Chmod(name string, mode os.FileMode) : error + Chtimes(name string, atime time.Time, mtime time.Time) : error Create(name string) : File, error Mkdir(name string, perm os.FileMode) : error MkdirAll(path string, perm os.FileMode) : error @@ -113,6 +115,22 @@ Methods Available: Rename(oldname, newname string) : error Stat(name string) : os.FileInfo, error +File Interfaces and Methods Available: + + io.Closer + io.Reader + io.ReaderAt + io.Seeker + io.Writer + io.WriterAt + + Stat() : os.FileInfo, error + Readdir(count int) : []os.FileInfo, error + Readdirnames(n int) : []string, error + WriteString(s string) : ret int, err error + Truncate(size int64) : error + Name() : string + In our case we would call `AppFs.Open()` as an example because that is how we’ve defined to access our filesystem. diff --git a/fs_test.go b/fs_test.go index 99ab330..92cbf6f 100644 --- a/fs_test.go +++ b/fs_test.go @@ -362,6 +362,7 @@ func TestReaddirSimple(t *testing.T) { func TestReaddir(t *testing.T) { for num := 0; num < 6; num++ { outputs := make([]string, len(Fss)) + infos := make([]string, len(Fss)) for i, fs := range Fss { root, err := fs.Open(testSubDir) if err != nil { @@ -370,15 +371,16 @@ func TestReaddir(t *testing.T) { for j := 0; j < 6; j++ { info, err := root.Readdir(num) outputs[i] += fmt.Sprintf("%v Error: %v\n", myFileInfo(info), err) + infos[i] += fmt.Sprintln(len(info), err) } } fail := false - for i, o := range outputs { + for i, o := range infos { if i == 0 { continue } - if o != outputs[i-1] { + if o != infos[i-1] { fail = true break }