add test(part)

This commit is contained in:
HouXiaoxuan
2023-12-23 22:16:27 +08:00
parent 2a16e577be
commit b918290c79
2 changed files with 22 additions and 1 deletions

View File

@@ -207,3 +207,25 @@ pub fn restore(paths: Vec<String>, 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());
}
}

View File

@@ -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| {