Add tests for handlers and fix path display bug

- Fix compilation error in path_utils.rs where path.display() was
  used after the path was moved into spawn_blocking closure
- Add 12 tests for handle_undo handler covering no undo log,
  no completed moves, custom paths, dry run, invalid paths, etc.
- Add 16 tests for validate_and_normalize_path covering path
  validation, directories, normalization, edge cases
- Add 21 tests for cache module covering key generation,
  hit/miss behavior, eviction, persistence, etc.

All 86 tests pass successfully.
This commit is contained in:
2026-01-11 22:31:43 +05:30
parent 3899f94c74
commit f68d960cfe
4 changed files with 1026 additions and 1 deletions

View File

@@ -22,9 +22,10 @@ pub async fn validate_and_normalize_path(path: &Path) -> Result<PathBuf, String>
.map_err(|e| format!("Cannot access directory '{}': {}", path.display(), e))?;
// canonicalize is sync-only, use spawn_blocking
let path_display = path.display().to_string();
let path_owned = path.to_path_buf();
tokio::task::spawn_blocking(move || path_owned.canonicalize())
.await
.map_err(|e| format!("Task failed: {}", e))?
.map_err(|e| format!("Failed to normalize path '{}': {}", path.display(), e))
.map_err(|e| format!("Failed to normalize path '{}': {}", path_display, e))
}