#![allow(clippy::unwrap_used)]
use crate::detect;
use crate::{CodeWalker, WalkConfig};
use std::fs;
use tempfile::tempdir;
#[test]
fn verify_tar_archive_is_detected_as_binary() {
let dir = tempdir().unwrap();
let p = dir.path().join("archive.tar");
let mut block = vec![b' '; 512];
block[257..263].copy_from_slice(b"ustar\0");
fs::write(&p, &block).unwrap();
let is_bin = detect::is_binary(&p).unwrap();
assert!(is_bin, "tar archive should be detected as binary (not text)");
}
#[test]
fn verify_root_symlink_test_helper() {
let dir = tempdir().unwrap();
let real = dir.path().join("real");
fs::create_dir_all(&real).unwrap();
fs::write(real.join("file.txt"), "hi").unwrap();
let link = dir.path().join("link");
#[cfg(unix)]
std::os::unix::fs::symlink(&real, &link).unwrap();
#[cfg(windows)]
std::os::windows::fs::symlink_dir(&real, &link).unwrap();
let walker = CodeWalker::new(&link, WalkConfig::default());
let entries = walker.walk().unwrap();
assert!(entries.iter().any(|e| e.path.file_name().unwrap() == "file.txt"));
}