diff --git a/fs_test.go b/fs_test.go index 36925e6..ec8e235 100644 --- a/fs_test.go +++ b/fs_test.go @@ -122,12 +122,20 @@ func TestRemove(t *testing.T) { err := fs.Remove(path) if err != nil { - t.Fatalf("%v: Remove() failed: %v", fs.Name(), err) + t.Errorf("%v: Remove() failed: %v", fs.Name(), err) + continue } _, err = fs.Stat(path) if !os.IsNotExist(err) { t.Errorf("%v: Remove() didn't remove file", fs.Name()) + continue + } + + // Deleting non-existent file should raise error + err = fs.Remove(path) + if !os.IsNotExist(err) { + t.Errorf("%v: Remove() didn't raise error for non-existent file", fs.Name()) } } } diff --git a/memmap.go b/memmap.go index b12969c..4513b15 100644 --- a/memmap.go +++ b/memmap.go @@ -178,6 +178,8 @@ func (m *MemMapFs) Remove(name string) error { if _, ok := m.getData()[name]; ok { delete(m.getData(), name) + } else { + return &os.PathError{"remove", name, os.ErrNotExist} } return nil }