diff --git a/crates/voelin-media/src/studio/output/record.rs b/crates/voelin-media/src/studio/output/record.rs index 29c5cb1..0c78cd3 100644 --- a/crates/voelin-media/src/studio/output/record.rs +++ b/crates/voelin-media/src/studio/output/record.rs @@ -350,7 +350,22 @@ mod tests { #[test] fn an_unwritable_path_fails_at_once() { - assert!(Recorder::start("/nonexistent-root-dir/x/clip.webm", 0, 2).is_err()); - assert!(Recorder::start("clip.mp4", 0, 2).is_err()); + let dir = dir("unwritable"); + // A path below a regular file fails for every user, root included + // (ENOTDIR). A directory that is merely missing would be created, and + // a read-only one is written to by root. + let file = dir.join("not-a-directory"); + std::fs::write(&file, b"x").unwrap(); + assert!(Recorder::start(file.join("x").join("clip.webm"), 0, 2).is_err()); + // The directory is there and the file cannot be created because the + // path names a directory (EISDIR, again for every user). + let named_like_a_file = dir.join("clip.webm"); + std::fs::create_dir(&named_like_a_file).unwrap(); + assert!(Recorder::start(&named_like_a_file, 0, 2).is_err()); + // A name that asks for no known container is refused before any file + // is created. + assert!(Recorder::start(dir.join("clip.mp4"), 0, 2).is_err()); + assert!(!dir.join("clip.mp4").exists()); + std::fs::remove_dir_all(&dir).ok(); } }