add test that shows a bug with FileMode not being set for MemMapFs directories, clean up tests

This commit is contained in:
Martin Bertschler 2017-10-03 23:17:35 +02:00
parent 8a6ade7159
commit 473997e418
5 changed files with 41 additions and 8 deletions

View File

@ -16,5 +16,6 @@ matrix:
fast_finish: true fast_finish: true
script: script:
- go test -race -v ./...
- go build - go build
- go test -race -v ./...

View File

@ -12,4 +12,4 @@ build_script:
go build github.com/spf13/afero go build github.com/spf13/afero
test_script: test_script:
- cmd: go test --race -v github.com/spf13/afero - cmd: go test -race -v github.com/spf13/afero/...

View File

@ -368,7 +368,7 @@ func TestUnionCacheExpire(t *testing.T) {
} }
} }
func TestCacheOnReadFs_Open_NotInLayer(t *testing.T) { func TestCacheOnReadFsNotInLayer(t *testing.T) {
base := NewMemMapFs() base := NewMemMapFs()
layer := NewMemMapFs() layer := NewMemMapFs()
fs := NewCacheOnReadFs(base, layer, 0) fs := NewCacheOnReadFs(base, layer, 0)

View File

@ -5,7 +5,7 @@ import (
"time" "time"
) )
func Test_FileData_Name_withConcurrence(t *testing.T) { func TestFileDataNameRace(t *testing.T) {
t.Parallel() t.Parallel()
const someName = "someName" const someName = "someName"
const someOtherName = "someOtherName" const someOtherName = "someOtherName"
@ -31,7 +31,7 @@ func Test_FileData_Name_withConcurrence(t *testing.T) {
} }
} }
func Test_FileData_ModTime_withConcurrence(t *testing.T) { func TestFileDataModTimeRace(t *testing.T) {
t.Parallel() t.Parallel()
someTime := time.Now() someTime := time.Now()
someOtherTime := someTime.Add(1 * time.Minute) someOtherTime := someTime.Add(1 * time.Minute)
@ -62,7 +62,7 @@ func Test_FileData_ModTime_withConcurrence(t *testing.T) {
} }
} }
func Test_FileData_Mode_withConcurrence(t *testing.T) { func TestFileDataModeRace(t *testing.T) {
t.Parallel() t.Parallel()
const someMode = 0777 const someMode = 0777
const someOtherMode = 0660 const someOtherMode = 0660
@ -93,7 +93,7 @@ func Test_FileData_Mode_withConcurrence(t *testing.T) {
} }
} }
func Test_FileData_IsDir_withConcurrence(t *testing.T) { func TestFileDataIsDirRace(t *testing.T) {
t.Parallel() t.Parallel()
d := FileData{ d := FileData{
@ -118,7 +118,7 @@ func Test_FileData_IsDir_withConcurrence(t *testing.T) {
t.Logf("Value is %v", s.IsDir()) t.Logf("Value is %v", s.IsDir())
} }
func Test_FileData_Size_withConcurrence(t *testing.T) { func TestFileDataSizeRace(t *testing.T) {
t.Parallel() t.Parallel()
const someData = "Hello" const someData = "Hello"

View File

@ -384,3 +384,35 @@ loop:
} }
} }
} }
func TestMemFsDirMode(t *testing.T) {
fs := NewMemMapFs()
err := fs.Mkdir("/testDir1", 0644)
if err != nil {
t.Error(err)
}
err = fs.MkdirAll("/sub/testDir2", 0644)
if err != nil {
t.Error(err)
}
info, err := fs.Stat("/testDir1")
if err != nil {
t.Error(err)
}
if !info.IsDir() {
t.Error("should be a directory")
}
if info.Mode()&os.ModeDir == 0 {
t.Error("FileMode is not directory")
}
info, err = fs.Stat("/sub/testDir2")
if err != nil {
t.Error(err)
}
if !info.IsDir() {
t.Error("should be a directory")
}
if info.Mode()&os.ModeDir == 0 {
t.Error("FileMode is not directory")
}
}