use super::*;
use std::fs;
use tempfile::TempDir;
#[test]
fn collect_files_direct_file_path_included() {
let dir = TempDir::new().unwrap();
let path = dir.path().join("a.txt");
fs::write(&path, "hello\n").unwrap();
let files = collect_files(std::slice::from_ref(&path), &[]);
assert_eq!(files, vec![path]);
}
#[test]
fn collect_files_direct_file_path_excluded_by_glob() {
let dir = TempDir::new().unwrap();
let path = dir.path().join("b.txt");
fs::write(&path, "hello\n").unwrap();
let files = collect_files(std::slice::from_ref(&path), &["**".into()]);
assert!(files.is_empty(), "file should be excluded by '**' pattern");
}
#[test]
fn collect_files_skips_hidden_entries() {
let dir = TempDir::new().unwrap();
fs::write(dir.path().join("visible.txt"), "visible\n").unwrap();
fs::write(dir.path().join(".hidden"), "hidden\n").unwrap();
let files = collect_files(&[dir.path().to_path_buf()], &[]);
assert!(files.iter().any(|f| f.ends_with("visible.txt")));
assert!(files.iter().all(|f| {
!f.file_name()
.and_then(|n| n.to_str())
.is_some_and(|s| s.starts_with('.'))
}));
}
#[test]
fn collect_files_nonexistent_path_warns_to_stderr() {
let path = std::path::PathBuf::from("/tmp/linecheck-test-nonexistent-path-xyz");
let files = collect_files(&[path], &[]);
assert!(files.is_empty());
}