diff --git a/pttodoest/src/main.rs b/pttodoest/src/main.rs index c3b4af5..c41a9d6 100755 --- a/pttodoest/src/main.rs +++ b/pttodoest/src/main.rs @@ -620,4 +620,32 @@ mod edit { Ok(()) } + + #[cfg(test)] + mod test_edit { + use super::*; + + #[test] + fn test_build_empty() { + tests::with_dir(|d| { + build_dir(&d, &Files { files: vec![] }).expect("failed to build empty dir"); + }); + } + + #[test] + fn test_build_with_files() { + tests::with_dir(|d1| { + tests::write_file(&d1, "file_a", "hello world a"); + tests::write_file(&d1, "file_b", "hello world b"); + let p1 = d1.path().join("file_a").display().to_string(); + let p2 = d1.path().join("file_b").display().to_string(); + let files = Files::new(&vec![p1, p2]); + tests::with_dir(|d2| { + build_dir(&d2, &files).expect("failed to build non-empty dir"); + tests::file_contains(&d2, "file_a", "hello world a"); + tests::file_contains(&d2, "file_b", "hello world b"); + }); + }); + } + } }