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:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user