From aa375d821674cd1feea81e27c2918d0429dd54f6 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 23 Sep 2024 22:16:54 +0200 Subject: cross device tests --- src/pathinfo.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/pathinfo.rs b/src/pathinfo.rs index 1231ff8..6ca6444 100644 --- a/src/pathinfo.rs +++ b/src/pathinfo.rs @@ -390,11 +390,15 @@ mod tests { #[test] fn compare_to_last_modified() -> color_eyre::Result<()> { + + let cwd = std::env::current_dir()?; + let test_dir = format!("{}/backup-test-dir", cwd.display()); + let mut config = Config::default(); config.root = "./backup-test".to_string(); config .directories - .push("u:fx/code/proj/arbs/backup-test-dir".to_string()); + .push(format!("r:{test_dir}")); create_dir_all("./backup-test-dir")?; let mut f = File::create("./backup-test-dir/size.txt")?; @@ -412,17 +416,21 @@ mod tests { let mut f = File::create("./backup-test-dir/content.txt")?; f.write_all("unmodefied".as_bytes())?; - let pi = PathInfo::from_path(&config, "u:fx/code/proj/arbs/backup-test-dir")?; + let pi = PathInfo::from_path(&config, format!("r:{test_dir}").as_str())?; + + let nothing_full = format!("{test_dir}/nothing.txt"); + let nothing = ¬hing_full[1..nothing_full.len()]; let last_backup = Backup::get_last(&config)?.unwrap(); for file in pi.children { println!("test rel: {}", file.rel_location); - let res = if file.rel_location == "code/proj/arbs/backup-test-dir/nothing.txt" { + println!("nothing: {}", nothing); + let res = if file.rel_location == nothing { Some(last_backup.id.clone()) } else { None }; - println!("Testing {file:?}"); + // println!("Testing {file:?}"); assert_eq!( PathInfo::compare_to_last_modified( &config, @@ -431,7 +439,7 @@ mod tests { )?, res ); - println!("\x1B[FTesting {file:?} ✓"); + // println!("\x1B[FTesting {file:?} ✓"); } remove_dir_all("./backup-test-dir")?; -- cgit v1.2.3