mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-02-03 10:14:13 +08:00
去除setup_with_mit,使用clarm_mit代替
This commit is contained in:
10
src/head.rs
10
src/head.rs
@@ -117,7 +117,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_edit_branch() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let branch_name = "test_branch".to_string() + &rand::random::<u32>().to_string();
|
||||
let branch_head = super::get_branch_head(&branch_name);
|
||||
assert!(branch_head.is_empty());
|
||||
@@ -131,7 +131,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_list_local_branches() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let branch_one = "test_branch".to_string() + &rand::random::<u32>().to_string();
|
||||
let branch_two = "test_branch".to_string() + &rand::random::<u32>().to_string();
|
||||
update_branch(&branch_one, &"1234567890".to_string());
|
||||
@@ -144,7 +144,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_change_head_to_branch() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let branch_name = "test_branch".to_string() + &rand::random::<u32>().to_string();
|
||||
update_branch(&branch_name, &"1234567890".to_string());
|
||||
super::change_head_to_branch(&branch_name);
|
||||
@@ -159,7 +159,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_change_head_to_commit() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let commit_hash = "1234567890".to_string();
|
||||
super::change_head_to_commit(&commit_hash);
|
||||
assert!(
|
||||
@@ -173,7 +173,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_update_branch_head() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let branch_name = "test_branch".to_string() + &rand::random::<u32>().to_string();
|
||||
let commit_hash = "1234567890".to_string();
|
||||
super::update_branch(&branch_name, &commit_hash);
|
||||
|
||||
@@ -190,7 +190,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_meta_get() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let metadata = fs::metadata(".mit/HEAD").unwrap();
|
||||
println!("{:?}", util::format_time(&metadata.created().unwrap()));
|
||||
println!("{:?}", util::format_time(&metadata.modified().unwrap()));
|
||||
@@ -199,7 +199,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_load() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let index = Index::new();
|
||||
println!("{:?}", index);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_new_success() {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let _ = Store::new();
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_save_and_load() {
|
||||
let _ = util::setup_test_with_mit();
|
||||
let _ = util::setup_test_with_clean_mit();
|
||||
let store = Store::new();
|
||||
let content = "hello world".to_string();
|
||||
let hash = store.save(&content);
|
||||
|
||||
@@ -77,6 +77,13 @@ pub fn ensure_test_file(path: &Path, content: option::Option<&str>) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ensure_no_file(path: &Path) {
|
||||
// 以测试目录为根目录,删除文件
|
||||
if path.exists() {
|
||||
fs::remove_file(get_working_dir().unwrap().join(path)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
/* tools for mit */
|
||||
pub fn calc_hash(data: &String) -> String {
|
||||
let mut hasher = Sha1::new();
|
||||
@@ -394,7 +401,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_is_inside_repo() {
|
||||
setup_test_with_mit();
|
||||
setup_test_with_clean_mit();
|
||||
let path = Path::new("../Cargo.toml");
|
||||
assert_eq!(is_inside_workdir(path), false);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ fn test_hash() {
|
||||
|
||||
#[test]
|
||||
fn test_write() -> Result<(), Error> {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let path = "lines.txt";
|
||||
//create会截断文件
|
||||
let mut output = File::create(path)?; // ? 用于传播错误
|
||||
@@ -24,7 +24,7 @@ fn test_write() -> Result<(), Error> {
|
||||
|
||||
#[test]
|
||||
fn test_read() -> Result<(), Error> {
|
||||
util::setup_test_with_mit();
|
||||
util::setup_test_with_clean_mit();
|
||||
let path = "lines.txt";
|
||||
util::ensure_test_file(path.as_ref(), None);
|
||||
let input = File::open(path)?;
|
||||
|
||||
Reference in New Issue
Block a user