mirror of https://github.com/spf13/afero.git
add test that shows a bug with FileMode not being set for MemMapFs directories, clean up tests
This commit is contained in:
parent
8a6ade7159
commit
473997e418
|
@ -16,5 +16,6 @@ matrix:
|
|||
fast_finish: true
|
||||
|
||||
script:
|
||||
- go test -race -v ./...
|
||||
- go build
|
||||
- go test -race -v ./...
|
||||
|
||||
|
|
|
@ -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/...
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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{
|
||||
|
@ -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"
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue