Fixes: Buchende-Position → Start von vorn (EOF-Idle-Bug: 'nichts abspielbar'), lokale Covers über Asset-URI, Test-Env-Races entfernt
This commit is contained in:
@ -717,21 +717,19 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn local_books_findet_testbuch() {
|
||||
// books_dir per env-Override — in Rust 2024 unsicher, deshalb unsafe-Block
|
||||
let tmp = std::env::temp_dir().join(format!("hw-localtest-{}", std::process::id()));
|
||||
unsafe {
|
||||
std::env::set_var("HOERWERK_BOOKS_DIR", &tmp);
|
||||
}
|
||||
let b = tmp.join("B08L4WJMDM");
|
||||
fs::create_dir_all(&b).unwrap();
|
||||
fs::write(b.join("book.m4b"), &vec![0u8; 4096]).unwrap();
|
||||
// eigener synthetic-Ordner im echten books_dir, ohne env (parallel-safe)
|
||||
let probe = crate::audible::books_dir()
|
||||
.join(format!("hwtest-{}", std::process::id()))
|
||||
.join("book.m4b");
|
||||
// Kein echtes ffprobe-nötiges Buch — es genügt, dass ER FUND wird
|
||||
// (probe_m4b fällt auf Ordnername zurück).
|
||||
let dir = probe.parent().unwrap();
|
||||
fs::create_dir_all(dir).unwrap();
|
||||
fs::write(&probe, &vec![0u8; 4096]).unwrap();
|
||||
let found = crate::audible::local_books();
|
||||
unsafe {
|
||||
std::env::remove_var("HOERWERK_BOOKS_DIR");
|
||||
}
|
||||
let hit = found.iter().any(|bk| bk.asin == "B08L4WJMDM" && bk.local);
|
||||
assert!(hit, "lokales Buch muss gefunden werden: {:?}", found.iter().map(|bk| bk.asin.clone()).collect::<Vec<_>>());
|
||||
let _ = fs::remove_dir_all(&tmp);
|
||||
let hit = found.iter().any(|bk| bk.asin == dir.file_name().unwrap().to_string_lossy());
|
||||
let _ = fs::remove_dir_all(crate::audible::books_dir().join(format!("hwtest-{}", std::process::id())));
|
||||
assert!(hit, "synthetisches lokales Buch muss gefunden werden");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -750,19 +748,12 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn alter_note_roundtrip() {
|
||||
let tmp = std::env::temp_dir().join(format!("hw-labels-{}", std::process::id()));
|
||||
unsafe {
|
||||
std::env::set_var("HOERWERK_BOOKS_DIR", &tmp);
|
||||
}
|
||||
crate::audible::set_alter_note("B08L4WJMDM", Some("ab 6".into())).unwrap();
|
||||
let key = format!("hwtest-{}", std::process::id());
|
||||
crate::audible::set_alter_note(&key, Some("ab 6".into())).unwrap();
|
||||
let l = crate::audible::alter_notes();
|
||||
assert_eq!(l.0.get("B08L4WJMDM").map(|s| s.as_str()), Some("ab 6"));
|
||||
crate::audible::set_alter_note("B08L4WJMDM", None).unwrap();
|
||||
assert!(crate::audible::alter_notes().0.get("B08L4WJMDM").is_none());
|
||||
unsafe {
|
||||
std::env::remove_var("HOERWERK_BOOKS_DIR");
|
||||
}
|
||||
let _ = fs::remove_dir_all(&tmp);
|
||||
assert_eq!(l.0.get(&key).map(|s| s.as_str()), Some("ab 6"));
|
||||
crate::audible::set_alter_note(&key, None).unwrap();
|
||||
assert!(crate::audible::alter_notes().0.get(&key).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user