From 585f9e1869cf8f9dbd6614e05b0d68b682fdb20e Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Thu, 28 Dec 2023 15:28:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AF=A5=E7=94=A8test=5Futil?= =?UTF-8?q?::setup=5Fempty=5Fdir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/commands/commit.rs | 3 +-- src/commands/merge.rs | 8 +++++--- src/commands/status.rs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/commands/commit.rs b/src/commands/commit.rs index 44b8bdb..101972d 100644 --- a/src/commands/commit.rs +++ b/src/commands/commit.rs @@ -46,8 +46,7 @@ mod test { #[test] #[should_panic] fn test_commit_empty() { - test_util::setup_test_with_clean_mit(); - + test_util::setup_test_with_empty_workdir(); super::commit("".to_string(), false); } diff --git a/src/commands/merge.rs b/src/commands/merge.rs index 8128fb7..f39c5dc 100644 --- a/src/commands/merge.rs +++ b/src/commands/merge.rs @@ -87,11 +87,10 @@ mod test { commands::{commit, switch::switch}, utils::util::test_util, }; + #[test] fn test_check_ff() { - test_util::setup_test_with_clean_mit(); - util::list_workdir_files().iter().for_each(|x| fs::remove_file(x).unwrap()); - + test_util::setup_test_with_empty_workdir(); commit::commit("init".to_string(), true); let commit1 = head::current_head_commit(); let origin_branch = match head::current_head() { @@ -106,6 +105,7 @@ mod test { assert_ne!(head::current_head_commit(), commit1); assert_eq!(head::get_branch_head(&origin_branch.clone()), commit1); let commit2 = head::current_head_commit(); + println!("[info] success create new branch: {}", new_branch); // test success merge switch(Some(origin_branch.clone()), None, false); @@ -115,11 +115,13 @@ mod test { assert!(result.is_ok()); assert_eq!(head::current_head_commit(), commit2); assert_eq!(head::get_branch_head(&origin_branch.clone()), commit2); + println!("[info] success merge ff"); // test no fast forward commit::commit("master commit 2".to_string(), true); let result = merge_ff(commit1.clone()); assert!(result.is_err()); assert!(matches!(result.unwrap_err(), MergeErr::NoFastForward)); + print!("success detect no fast forward"); } } diff --git a/src/commands/status.rs b/src/commands/status.rs index 362555b..39c1aea 100644 --- a/src/commands/status.rs +++ b/src/commands/status.rs @@ -201,7 +201,7 @@ mod tests { #[test] fn test_changes_to_be_committed() { - test_util::setup_test_with_clean_mit(); + test_util::setup_test_with_empty_workdir(); let test_file = "a.txt"; test_util::ensure_test_file(Path::new(test_file), None);