summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pathinfo.rs18
1 files changed, 13 insertions, 5 deletions
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 {
390 390
391 #[test] 391 #[test]
392 fn compare_to_last_modified() -> color_eyre::Result<()> { 392 fn compare_to_last_modified() -> color_eyre::Result<()> {
393
394 let cwd = std::env::current_dir()?;
395 let test_dir = format!("{}/backup-test-dir", cwd.display());
396
393 let mut config = Config::default(); 397 let mut config = Config::default();
394 config.root = "./backup-test".to_string(); 398 config.root = "./backup-test".to_string();
395 config 399 config
396 .directories 400 .directories
397 .push("u:fx/code/proj/arbs/backup-test-dir".to_string()); 401 .push(format!("r:{test_dir}"));
398 402
399 create_dir_all("./backup-test-dir")?; 403 create_dir_all("./backup-test-dir")?;
400 let mut f = File::create("./backup-test-dir/size.txt")?; 404 let mut f = File::create("./backup-test-dir/size.txt")?;
@@ -412,17 +416,21 @@ mod tests {
412 let mut f = File::create("./backup-test-dir/content.txt")?; 416 let mut f = File::create("./backup-test-dir/content.txt")?;
413 f.write_all("unmodefied".as_bytes())?; 417 f.write_all("unmodefied".as_bytes())?;
414 418
415 let pi = PathInfo::from_path(&config, "u:fx/code/proj/arbs/backup-test-dir")?; 419 let pi = PathInfo::from_path(&config, format!("r:{test_dir}").as_str())?;
420
421 let nothing_full = format!("{test_dir}/nothing.txt");
422 let nothing = &nothing_full[1..nothing_full.len()];
416 423
417 let last_backup = Backup::get_last(&config)?.unwrap(); 424 let last_backup = Backup::get_last(&config)?.unwrap();
418 for file in pi.children { 425 for file in pi.children {
419 println!("test rel: {}", file.rel_location); 426 println!("test rel: {}", file.rel_location);
420 let res = if file.rel_location == "code/proj/arbs/backup-test-dir/nothing.txt" { 427 println!("nothing: {}", nothing);
428 let res = if file.rel_location == nothing {
421 Some(last_backup.id.clone()) 429 Some(last_backup.id.clone())
422 } else { 430 } else {
423 None 431 None
424 }; 432 };
425 println!("Testing {file:?}"); 433 // println!("Testing {file:?}");
426 assert_eq!( 434 assert_eq!(
427 PathInfo::compare_to_last_modified( 435 PathInfo::compare_to_last_modified(
428 &config, 436 &config,
@@ -431,7 +439,7 @@ mod tests {
431 )?, 439 )?,
432 res 440 res
433 ); 441 );
434 println!("\x1B[FTesting {file:?} ✓"); 442 // println!("\x1B[FTesting {file:?} ✓");
435 } 443 }
436 444
437 remove_dir_all("./backup-test-dir")?; 445 remove_dir_all("./backup-test-dir")?;