From fed821ebd28b8a5e9087ddb3ec0ad920523b8c98 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 29 Jul 2020 01:31:56 +0200 Subject: suggestion.rs: Remove research tests These weren't actual tests. I was using them to research different implementation approaches. --- src/suggestion.rs | 74 ------------------------------------------------------- 1 file changed, 74 deletions(-) diff --git a/src/suggestion.rs b/src/suggestion.rs index 0e9b7b8..2c92e6a 100644 --- a/src/suggestion.rs +++ b/src/suggestion.rs @@ -199,80 +199,6 @@ fn is_line_crlf(line: &str) -> bool { mod tests { use super::*; - #[test] - fn unified_diff() { - use unidiff::PatchSet; - - let diff = r#"--- a/command/pr.go -+++ b/command/pr.go -@@ -1,9 +1,11 @@ - package command - - import ( -+ "bufio" // used to input comment - "errors" - "fmt" - "io" -+ "os" // used to input comment -"#; - - let mut patch = PatchSet::new(); - patch.parse(diff).unwrap(); - - println!("{:?}", patch); - println!("{}", patch); - - let lines = patch.files_mut()[0].hunks_mut()[0].lines_mut(); - - // for line in &lines { - // if line.is_removed() { - // } else if line.is_added() { - // line.line_type = unidiff::LINE_TYPE_CONTEXT.to_owned(); - // } - // } - - lines - .iter_mut() - .filter(|l| !l.is_removed()) - // .map(|l| { - .for_each(|l| { - if l.is_added() { - l.line_type = unidiff::LINE_TYPE_CONTEXT.to_owned(); - } - }); - - lines[lines.len() - 2].line_type = unidiff::LINE_TYPE_REMOVED.to_owned(); - - patch.files_mut()[0].hunks_mut()[0].append(unidiff::Line::new( - r#" "os""#, - unidiff::LINE_TYPE_ADDED, - )); - - println!("{}", patch); - } - - #[test] - fn read_git_blob() { - use std::path::Path; - - use git2::Repository; - - let repo = Repository::open("./private/suggestion-test").unwrap(); - let commit = repo.find_commit("b58be52880a0a0c0d397052351be31f19acdeca4".parse().unwrap()).unwrap(); - - let object = commit - .tree().unwrap() - .get_path(Path::new("src/server.rs")).unwrap() - .to_object(&repo).unwrap(); - - let blob = object - .as_blob().unwrap() - .content(); - - println!("{:?}", commit); - println!("{}", std::str::from_utf8(blob).unwrap()); - } - #[test] fn suggestion_diff_with_repo_generates_diff() { use tempfile::tempdir; -- cgit v1.2.3