From 34c5f367f740012a0cb4307c198f3ca8a84f6035 Mon Sep 17 00:00:00 2001 From: Micha Bar-Shalev Date: Sun, 25 Jun 2023 15:52:59 +0300 Subject: [PATCH 1/2] increasing code coverage issue #46 --- src/git_theme.rs | 25 +++++++++++++++++++++++++ src/main.rs | 13 +++++++++++++ src/meta/name.rs | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/git_theme.rs b/src/git_theme.rs index 27bd965e6..294f6cbdb 100644 --- a/src/git_theme.rs +++ b/src/git_theme.rs @@ -29,3 +29,28 @@ impl GitTheme { symbol.to_string() } } + +#[test] +fn test_git_get_symbol() { + let git_theme = GitTheme::new(); + let mut git_status = GitStatus::Default; + assert_eq!(git_theme.get_symbol(&git_status), "-".to_string()); + git_status = GitStatus::Unmodified; + assert_eq!(git_theme.get_symbol(&git_status), ".".to_string()); + git_status = GitStatus::Ignored; + assert_eq!(git_theme.get_symbol(&git_status), "I".to_string()); + git_status = GitStatus::NewInIndex; + assert_eq!(git_theme.get_symbol(&git_status), "N".to_string()); + git_status = GitStatus::NewInWorkdir; + assert_eq!(git_theme.get_symbol(&git_status), "?".to_string()); + git_status = GitStatus::Typechange; + assert_eq!(git_theme.get_symbol(&git_status), "T".to_string()); + git_status = GitStatus::Deleted; + assert_eq!(git_theme.get_symbol(&git_status), "D".to_string()); + git_status = GitStatus::Renamed; + assert_eq!(git_theme.get_symbol(&git_status), "R".to_string()); + git_status = GitStatus::Modified; + assert_eq!(git_theme.get_symbol(&git_status), "M".to_string()); + git_status = GitStatus::Conflicted; + assert_eq!(git_theme.get_symbol(&git_status), "C".to_string()); +} diff --git a/src/main.rs b/src/main.rs index 1f7dd227c..7b09e7c3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -124,3 +124,16 @@ fn main() { let exit_code = core.run(cli.inputs); std::process::exit(exit_code as i32); } + +#[test] +fn test_print_output() { + let path = std::path::Path::new("."); + std::process::Command::new("lsd") + .arg(path.as_os_str()) + .spawn() + .expect("lsd command failed") + .wait() + .expect("wait failed"); + +} + diff --git a/src/meta/name.rs b/src/meta/name.rs index fbd4e1730..a01851a13 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -273,7 +273,7 @@ mod test { fs::create_dir(&dir_path).expect("failed to create the dir"); let meta = Meta::from_path(&dir_path, false).unwrap(); - let colors = Colors::new(color::ThemeOption::NoLscolors); + let colors = Colors::new(color::ThemeOption::Default); assert_eq!( " directory".to_string().with(Color::AnsiValue(33)), From 4b84ec4b252cb0fa2c6398d06906928543398233 Mon Sep 17 00:00:00 2001 From: Micha Bar-Shalev Date: Mon, 3 Jul 2023 12:34:23 +0300 Subject: [PATCH 2/2] main test --- src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7b09e7c3b..4fb44c6aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -134,6 +134,4 @@ fn test_print_output() { .expect("lsd command failed") .wait() .expect("wait failed"); - } -