From b918290c79f64a138cd599d3cb453b8aadfbee21 Mon Sep 17 00:00:00 2001 From: HouXiaoxuan Date: Sat, 23 Dec 2023 22:16:27 +0800 Subject: [PATCH] add test(part) --- src/commands/restore.rs | 22 ++++++++++++++++++++++ src/commands/switch.rs | 1 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/commands/restore.rs b/src/commands/restore.rs index 2edae55..1fb54c5 100644 --- a/src/commands/restore.rs +++ b/src/commands/restore.rs @@ -207,3 +207,25 @@ pub fn restore(paths: Vec, source: String, worktree: bool, staged: bool) restore_index(Some(&paths), &target_blobs); } } + +#[cfg(test)] +mod test { + use std::path::PathBuf; + + use crate::{ + commands, + models::index::Index, + utils::util::{self, ensure_no_file}, + }; + + #[test] + fn test_restore_stage() { + util::setup_test_with_clean_mit(); + let path = PathBuf::from("a.txt"); + util::ensure_no_file(&path); + commands::add::add(vec![], true, false); + super::restore(vec![".".to_string()], "HEAD".to_string(), false, true); + let index = Index::new(); + assert!(index.get_tracked_files().is_empty()); + } +} diff --git a/src/commands/switch.rs b/src/commands/switch.rs index eab2578..28961f7 100644 --- a/src/commands/switch.rs +++ b/src/commands/switch.rs @@ -91,7 +91,6 @@ mod test { use super::*; #[test] - // #[ignore] // TODO 等待restore实现后再测试 fn test_switch() { util::setup_test_with_clean_mit(); util::list_workdir_files().iter().for_each(|f| {