test: add test cases for filename conflicts and existing target directories#80
Conversation
…tories Signed-off-by: Tianze <tianzeshi_study@outlook.com>
There was a problem hiding this comment.
Pull request overview
This PR adds three integration test cases to tests/command/clone_test.rs to improve test coverage for edge cases related to directory conflicts during clone operations. The tests verify that the clone command correctly handles scenarios where the target path already exists in various states: as an empty directory (should succeed), as a non-empty directory (should fail), and as a file (should fail).
Key Changes:
- Added
test_clone_to_existing_empty_dirto verify cloning succeeds into a pre-existing empty directory - Added
test_clone_to_existing_dirto verify cloning fails when the target directory contains files - Added
test_clone_to_dir_with_existing_file_nameto verify cloning fails when the target path is an existing file
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Tianze <tianzeshi_study@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| // Make sure that the pre-existing file should still exist | ||
| assert!(dummy_file.exists(), "pre-existing file should still exist"); | ||
| let content = std::fs::read_to_string(&dummy_file).unwrap(); | ||
| // Make sure that the pre-existing file content should remain unchanged |
There was a problem hiding this comment.
[nitpick] The comment "Make sure that the pre-existing file content should remain unchanged" is redundant with the assertion message. Consider removing the comment or making it more informative.
| conflict_path.is_file(), | ||
| "pre-existing file should remain a file" | ||
| ); | ||
| // Make sure that the pre-existing file should still exist |
There was a problem hiding this comment.
[nitpick] The comment "Make sure that the pre-existing file should still exist" is redundant with the assertion message. Consider removing the comment or making it more informative.
| // Make sure that the pre-existing file should still exist |
Resolve #79
增加了三个测试用例,覆盖文件名冲突和目标文件夹已存在的边际条件
clone命令正确运行,并创建预期的目录结构
clone命令需要终止,不能在目标目录中创建仓库结构,并防止覆盖已有文件
clone命令能正确处理文件名冲突的情况,且不会覆盖已有同名的文件