mirror of https://github.com/spf13/afero.git
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
This commit is contained in:
parent
10150bfa64
commit
171091926d
20
README.md
20
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
|
Then throughout your functions and methods use the methods familiar
|
||||||
already from the OS package.
|
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
|
Create(name string) : File, error
|
||||||
Mkdir(name string, perm os.FileMode) : error
|
Mkdir(name string, perm os.FileMode) : error
|
||||||
MkdirAll(path string, perm os.FileMode) : error
|
MkdirAll(path string, perm os.FileMode) : error
|
||||||
|
@ -113,6 +115,22 @@ Methods Available:
|
||||||
Rename(oldname, newname string) : error
|
Rename(oldname, newname string) : error
|
||||||
Stat(name string) : os.FileInfo, 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
|
In our case we would call `AppFs.Open()` as an example because that is how we’ve defined to
|
||||||
access our filesystem.
|
access our filesystem.
|
||||||
|
|
||||||
|
|
|
@ -362,6 +362,7 @@ func TestReaddirSimple(t *testing.T) {
|
||||||
func TestReaddir(t *testing.T) {
|
func TestReaddir(t *testing.T) {
|
||||||
for num := 0; num < 6; num++ {
|
for num := 0; num < 6; num++ {
|
||||||
outputs := make([]string, len(Fss))
|
outputs := make([]string, len(Fss))
|
||||||
|
infos := make([]string, len(Fss))
|
||||||
for i, fs := range Fss {
|
for i, fs := range Fss {
|
||||||
root, err := fs.Open(testSubDir)
|
root, err := fs.Open(testSubDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -370,15 +371,16 @@ func TestReaddir(t *testing.T) {
|
||||||
for j := 0; j < 6; j++ {
|
for j := 0; j < 6; j++ {
|
||||||
info, err := root.Readdir(num)
|
info, err := root.Readdir(num)
|
||||||
outputs[i] += fmt.Sprintf("%v Error: %v\n", myFileInfo(info), err)
|
outputs[i] += fmt.Sprintf("%v Error: %v\n", myFileInfo(info), err)
|
||||||
|
infos[i] += fmt.Sprintln(len(info), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fail := false
|
fail := false
|
||||||
for i, o := range outputs {
|
for i, o := range infos {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if o != outputs[i-1] {
|
if o != infos[i-1] {
|
||||||
fail = true
|
fail = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue