forked from mirror/afero
Merge pull request #334 from KastenMike/add-modTime-to-folders
add modTime on folder creation
This commit is contained in:
commit
450b30f2bf
|
@ -71,7 +71,7 @@ func CreateFile(name string) *FileData {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateDir(name string) *FileData {
|
func CreateDir(name string) *FileData {
|
||||||
return &FileData{name: name, memDir: &DirMap{}, dir: true}
|
return &FileData{name: name, memDir: &DirMap{}, dir: true, modtime: time.Now()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChangeFileName(f *FileData, newname string) {
|
func ChangeFileName(f *FileData, newname string) {
|
||||||
|
|
|
@ -450,6 +450,9 @@ func TestMemFsMkdirAllMode(t *testing.T) {
|
||||||
if !info.Mode().IsDir() {
|
if !info.Mode().IsDir() {
|
||||||
t.Error("/a: mode is not directory")
|
t.Error("/a: mode is not directory")
|
||||||
}
|
}
|
||||||
|
if !info.ModTime().After(time.Now().Add(-1 * time.Hour)) {
|
||||||
|
t.Errorf("/a: mod time not set, got %s", info.ModTime())
|
||||||
|
}
|
||||||
if info.Mode() != os.FileMode(os.ModeDir|0755) {
|
if info.Mode() != os.FileMode(os.ModeDir|0755) {
|
||||||
t.Errorf("/a: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
|
t.Errorf("/a: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
|
||||||
}
|
}
|
||||||
|
@ -463,6 +466,9 @@ func TestMemFsMkdirAllMode(t *testing.T) {
|
||||||
if info.Mode() != os.FileMode(os.ModeDir|0755) {
|
if info.Mode() != os.FileMode(os.ModeDir|0755) {
|
||||||
t.Errorf("/a/b: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
|
t.Errorf("/a/b: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
|
||||||
}
|
}
|
||||||
|
if !info.ModTime().After(time.Now().Add(-1 * time.Hour)) {
|
||||||
|
t.Errorf("/a/b: mod time not set, got %s", info.ModTime())
|
||||||
|
}
|
||||||
info, err = fs.Stat("/a/b/c")
|
info, err = fs.Stat("/a/b/c")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -473,6 +479,9 @@ func TestMemFsMkdirAllMode(t *testing.T) {
|
||||||
if info.Mode() != os.FileMode(os.ModeDir|0755) {
|
if info.Mode() != os.FileMode(os.ModeDir|0755) {
|
||||||
t.Errorf("/a/b/c: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
|
t.Errorf("/a/b/c: wrong permissions, expected drwxr-xr-x, got %s", info.Mode())
|
||||||
}
|
}
|
||||||
|
if !info.ModTime().After(time.Now().Add(-1 * time.Hour)) {
|
||||||
|
t.Errorf("/a/b/c: mod time not set, got %s", info.ModTime())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MkdirAll does not change permissions of already-existing directories
|
// MkdirAll does not change permissions of already-existing directories
|
||||||
|
|
Loading…
Reference in New Issue