Implement MoveFile functionality in FileManager and corresponding tests

This commit is contained in:
2025-07-11 19:49:08 +02:00
parent 5a6895ecdc
commit 9bb95f603c
4 changed files with 158 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ type mockFS struct {
// Record operations for verification
ReadCalls map[string]int
WriteCalls map[string][]byte
MoveCalls map[string]string
RemoveCalls []string
MkdirCalls []string
@@ -56,6 +57,7 @@ type mockFS struct {
err error
}
WriteFileError error
MoveFileError error
RemoveError error
MkdirError error
StatError error
@@ -66,6 +68,7 @@ func NewMockFS() *mockFS {
return &mockFS{
ReadCalls: make(map[string]int),
WriteCalls: make(map[string][]byte),
MoveCalls: make(map[string]string),
RemoveCalls: make([]string, 0),
MkdirCalls: make([]string, 0),
ReadFileReturns: make(map[string]struct {
@@ -88,6 +91,14 @@ func (m *mockFS) WriteFile(path string, data []byte, _ fs.FileMode) error {
return m.WriteFileError
}
func (m *mockFS) MoveFile(src, dst string) error {
m.MoveCalls[src] = dst
if src == dst {
return nil // No-op if source and destination are the same
}
return m.MoveFileError
}
func (m *mockFS) Remove(path string) error {
m.RemoveCalls = append(m.RemoveCalls, path)
return m.RemoveError