Skip to content

Comments

test: add test cases for filename conflicts and existing target directories#80

Merged
genedna merged 5 commits intoweb3infra-foundation:mainfrom
tianzeshi-study:testCloneToExistingDir
Dec 8, 2025
Merged

test: add test cases for filename conflicts and existing target directories#80
genedna merged 5 commits intoweb3infra-foundation:mainfrom
tianzeshi-study:testCloneToExistingDir

Conversation

@tianzeshi-study
Copy link
Contributor

Resolve #79

增加了三个测试用例,覆盖文件名冲突和目标文件夹已存在的边际条件

  1. 目标文件夹已存在但为空: test_clone_to_existing_empty_dir
    clone命令正确运行,并创建预期的目录结构
  2. 目标文件夹存在并且不为空: test_clone_to_existing_dir
    clone命令需要终止,不能在目标目录中创建仓库结构,并防止覆盖已有文件
  3. 具有与目标文件夹同名的文件: test_clone_to_dir_with_existing_file_name
    clone命令能正确处理文件名冲突的情况,且不会覆盖已有同名的文件

…tories

Signed-off-by: Tianze <tianzeshi_study@outlook.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dir to verify cloning succeeds into a pre-existing empty directory
  • Added test_clone_to_existing_dir to verify cloning fails when the target directory contains files
  • Added test_clone_to_dir_with_existing_file_name to verify cloning fails when the target path is an existing file

tianzeshi-study and others added 3 commits December 8, 2025 15:57
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

// 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
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Copilot uses AI. Check for mistakes.
conflict_path.is_file(),
"pre-existing file should remain a file"
);
// Make sure that the pre-existing file should still exist
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Suggested change
// Make sure that the pre-existing file should still exist

Copilot uses AI. Check for mistakes.
@genedna genedna merged commit 1eeff39 into web3infra-foundation:main Dec 8, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[r2cn-测试任务] 为clone命令添加文件夹已存在的测试用例

2 participants