use hunch::Pipeline;
#[test]
fn issue_97_dir_name_discarded_without_fallback() {
let pipeline = Pipeline::new();
let siblings = vec![
"tv/Anime/Show/[Group][Title][02][1080P].mkv",
"tv/Anime/Show/[Group][Title][03][1080P].mkv",
];
let result = pipeline.run_with_context_and_fallback(
"tv/Anime/Show/[Group][Title][01][1080P].mkv",
&siblings,
None, );
let title = result.title().unwrap_or("");
assert_ne!(title, "Anime", "dir name should not become the title");
assert_ne!(title, "tv", "dir name should not become the title");
assert_ne!(
title, "tv Anime",
"compound dir names should not be the title"
);
}
#[test]
fn issue_97_non_consecutive_dir_names_detected() {
let pipeline = Pipeline::new();
let siblings = vec![
"tv/Anime/ShowDir/特典映像/[Group][Title][NC.Ver][1080P].mkv",
"tv/Anime/ShowDir/特典映像/[Group][Title][TalkShow][1080P].mkv",
];
let result = pipeline.run_with_context_and_fallback(
"tv/Anime/ShowDir/特典映像/[Group][Title][Concert][1080P].mkv",
&siblings,
None,
);
let title = result.title().unwrap_or("");
assert_ne!(title, "Anime");
assert_ne!(title, "特典映像");
assert!(
!title.contains("Anime") || title.len() > 10,
"title should not be purely directory names, got: {title:?}"
);
}
#[test]
fn issue_97_fallback_still_works_through_chain() {
let pipeline = Pipeline::new();
let siblings = vec![
"Show/Extras/Making.Of.720p.mkv",
"Show/Extras/Gag.Reel.720p.mkv",
];
let result = pipeline.run_with_context_and_fallback(
"Show/Extras/Interview.720p.mkv",
&siblings,
Some("Natsume Yuujinchou Shichi"), );
let title = result.title().unwrap_or("");
assert_eq!(
title, "Natsume Yuujinchou Shichi",
"parent fallback should propagate through to child"
);
}