Skip to content

Commit

Permalink
add test that shows a bug with FileMode not being set for MemMapFs di…
Browse files Browse the repository at this point in the history
…rectories, clean up tests
  • Loading branch information
mbertschler committed Oct 3, 2017
1 parent 8a6ade7 commit 473997e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -16,5 +16,6 @@ matrix:
fast_finish: true

script:
- go test -race -v ./...
- go build
- go test -race -v ./...

2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -12,4 +12,4 @@ build_script:
go build github.com/spf13/afero
test_script:
- cmd: go test --race -v github.com/spf13/afero
- cmd: go test -race -v github.com/spf13/afero/...
2 changes: 1 addition & 1 deletion composite_test.go
Expand Up @@ -368,7 +368,7 @@ func TestUnionCacheExpire(t *testing.T) {
}
}

func TestCacheOnReadFs_Open_NotInLayer(t *testing.T) {
func TestCacheOnReadFsNotInLayer(t *testing.T) {
base := NewMemMapFs()
layer := NewMemMapFs()
fs := NewCacheOnReadFs(base, layer, 0)
Expand Down
10 changes: 5 additions & 5 deletions mem/file_test.go
Expand Up @@ -5,7 +5,7 @@ import (
"time"
)

func Test_FileData_Name_withConcurrence(t *testing.T) {
func TestFileDataNameRace(t *testing.T) {
t.Parallel()
const someName = "someName"
const someOtherName = "someOtherName"
Expand All @@ -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()
someTime := time.Now()
someOtherTime := someTime.Add(1 * time.Minute)
Expand Down Expand Up @@ -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()
const someMode = 0777
const someOtherMode = 0660
Expand Down Expand Up @@ -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()

d := FileData{
Expand All @@ -118,7 +118,7 @@ func Test_FileData_IsDir_withConcurrence(t *testing.T) {
t.Logf("Value is %v", s.IsDir())
}

func Test_FileData_Size_withConcurrence(t *testing.T) {
func TestFileDataSizeRace(t *testing.T) {
t.Parallel()

const someData = "Hello"
Expand Down
32 changes: 32 additions & 0 deletions memmap_test.go
Expand Up @@ -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")
}
}

0 comments on commit 473997e

Please sign in to comment.