diff --git a/src/meta/filetype.rs b/src/meta/filetype.rs index aa3f45bf5..e3fa1cc9e 100644 --- a/src/meta/filetype.rs +++ b/src/meta/filetype.rs @@ -112,7 +112,6 @@ mod test { #[cfg(unix)] use crate::meta::Permissions; use crossterm::style::{Color, Stylize}; - #[cfg(unix)] use std::fs::File; #[cfg(unix)] use std::os::unix::fs::symlink; @@ -281,4 +280,42 @@ mod test { file_type.render(&colors) ); } + + #[cfg(windows)] + #[test] + fn test_file_executable() { + let tmp_dir = tempdir().expect("failed to create temp dir"); + for ext in FileType::EXECUTABLE_EXTENSIONS { + // Create the file; + let file_path = tmp_dir.path().join(format!("file.{ext}")); + File::create(&file_path).expect("failed to create file"); + let meta = file_path.metadata().expect("failed to get metas"); + + let colors = Colors::new(ThemeOption::NoLscolors); + let file_type = FileType::new(&meta, None, &file_path); + + assert_eq!( + ".".to_string().with(Color::AnsiValue(40)), + file_type.render(&colors) + ); + } + } + + #[cfg(windows)] + #[test] + fn test_file_not_executable() { + let tmp_dir = tempdir().expect("failed to create temp dir"); + // Create the file; + let file_path = tmp_dir.path().join("file.txt"); + File::create(&file_path).expect("failed to create file"); + let meta = file_path.metadata().expect("failed to get metas"); + + let colors = Colors::new(ThemeOption::NoLscolors); + let file_type = FileType::new(&meta, None, &file_path); + + assert_eq!( + ".".to_string().with(Color::AnsiValue(184)), + file_type.render(&colors) + ); + } }