mirror of
https://github.com/lsd-rs/lsd
synced 2024-11-13 23:57:08 +00:00
update symlink test and repeat test for dirs too
This commit is contained in:
parent
b15258006e
commit
05c0888979
1 changed files with 31 additions and 2 deletions
|
@ -200,7 +200,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
#[cfg(unix)] // Symlinks are hard on Windows
|
||||
fn test_print_symlink_name() {
|
||||
fn test_print_symlink_name_file() {
|
||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||
let icons = Icons::new(icon::Theme::Fancy);
|
||||
|
||||
|
@ -214,9 +214,10 @@ mod test {
|
|||
let meta = symlink_path
|
||||
.symlink_metadata()
|
||||
.expect("failed to get metas");
|
||||
let target_meta = symlink_path.metadata().ok();
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let file_type = FileType::new(&meta, Some(&meta), &Permissions::from(&meta));
|
||||
let file_type = FileType::new(&meta, target_meta.as_ref(), &Permissions::from(&meta));
|
||||
let name = Name::new(&symlink_path, file_type);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -225,6 +226,34 @@ mod test {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)] // Symlinks are hard on Windows
|
||||
fn test_print_symlink_name_dir() {
|
||||
let tmp_dir = tempdir().expect("failed to create temp dir");
|
||||
let icons = Icons::new(icon::Theme::Fancy);
|
||||
|
||||
// Create the file;
|
||||
let dir_path = tmp_dir.path().join("tmp.d");
|
||||
std::fs::create_dir(&dir_path).expect("failed to create dir");
|
||||
|
||||
// Create the symlink
|
||||
let symlink_path = tmp_dir.path().join("target.d");
|
||||
symlink(&dir_path, &symlink_path).expect("failed to create symlink");
|
||||
let meta = symlink_path
|
||||
.symlink_metadata()
|
||||
.expect("failed to get metas");
|
||||
let target_meta = symlink_path.metadata().ok();
|
||||
|
||||
let colors = Colors::new(color::Theme::NoLscolors);
|
||||
let file_type = FileType::new(&meta, target_meta.as_ref(), &Permissions::from(&meta));
|
||||
let name = Name::new(&symlink_path, file_type);
|
||||
|
||||
assert_eq!(
|
||||
Colour::Fixed(44).paint(" target.d"),
|
||||
name.render(&colors, &icons, &DisplayOption::FileName)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
fn test_print_other_type_name() {
|
||||
|
|
Loading…
Reference in a new issue