diff options
author | fxqnlr <[email protected]> | 2024-09-29 15:31:54 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-29 15:31:54 +0200 |
commit | 83ac2ad62c27a3089f892b409405f74c4952f2da (patch) | |
tree | 176b819060c5da7ae83510bedec784401a7533d1 /src/pathinfo.rs | |
parent | 5f23d5506698081722eef6e34f11c7fb24e0b212 (diff) | |
parent | d1a9d0d8a8746a63b93f8f14ee4f51b1cd240349 (diff) | |
download | arbs-83ac2ad62c27a3089f892b409405f74c4952f2da.tar arbs-83ac2ad62c27a3089f892b409405f74c4952f2da.tar.gz arbs-83ac2ad62c27a3089f892b409405f74c4952f2da.zip |
Merge remote-tracking branch 'origin/dnf'
Diffstat (limited to 'src/pathinfo.rs')
-rw-r--r-- | src/pathinfo.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/pathinfo.rs b/src/pathinfo.rs index 009f46a..80614cd 100644 --- a/src/pathinfo.rs +++ b/src/pathinfo.rs | |||
@@ -392,11 +392,16 @@ mod tests { | |||
392 | } | 392 | } |
393 | 393 | ||
394 | #[test] | 394 | #[test] |
395 | fn compare_to_last_modified() -> Result<()> { | 395 | fn compare_to_last_modified() -> color_eyre::Result<()> { |
396 | let mut config = Config { root: "./backup-test".to_string(), ..Default::default() }; | 396 | |
397 | let cwd = std::env::current_dir()?; | ||
398 | let test_dir = format!("{}/backup-test-dir", cwd.display()); | ||
399 | |||
400 | let mut config = Config::default(); | ||
401 | config.root = "./backup-test".to_string(); | ||
397 | config | 402 | config |
398 | .directories | 403 | .directories |
399 | .push("u:fx/code/proj/arbs/backup-test-dir".to_string()); | 404 | .push(format!("r:{test_dir}")); |
400 | 405 | ||
401 | create_dir_all("./backup-test-dir")?; | 406 | create_dir_all("./backup-test-dir")?; |
402 | let mut f = File::create("./backup-test-dir/size.txt")?; | 407 | let mut f = File::create("./backup-test-dir/size.txt")?; |
@@ -414,17 +419,21 @@ mod tests { | |||
414 | let mut f = File::create("./backup-test-dir/content.txt")?; | 419 | let mut f = File::create("./backup-test-dir/content.txt")?; |
415 | f.write_all("unmodefied".as_bytes())?; | 420 | f.write_all("unmodefied".as_bytes())?; |
416 | 421 | ||
417 | let pi = PathInfo::from_path(&config, "u:fx/code/proj/arbs/backup-test-dir")?; | 422 | let pi = PathInfo::from_path(&config, format!("r:{test_dir}").as_str())?; |
423 | |||
424 | let nothing_full = format!("{test_dir}/nothing.txt"); | ||
425 | let nothing = ¬hing_full[1..nothing_full.len()]; | ||
418 | 426 | ||
419 | let last_backup = Backup::get_last(&config)?.unwrap(); | 427 | let last_backup = Backup::get_last(&config)?.unwrap(); |
420 | for file in pi.children { | 428 | for file in pi.children { |
421 | println!("test rel: {}", file.rel_location); | 429 | println!("test rel: {}", file.rel_location); |
422 | let res = if file.rel_location == "code/proj/arbs/backup-test-dir/nothing.txt" { | 430 | println!("nothing: {}", nothing); |
431 | let res = if file.rel_location == nothing { | ||
423 | Some(last_backup.id.clone()) | 432 | Some(last_backup.id.clone()) |
424 | } else { | 433 | } else { |
425 | None | 434 | None |
426 | }; | 435 | }; |
427 | println!("Testing {file:?}"); | 436 | // println!("Testing {file:?}"); |
428 | assert_eq!( | 437 | assert_eq!( |
429 | PathInfo::compare_to_last_modified( | 438 | PathInfo::compare_to_last_modified( |
430 | &config, | 439 | &config, |
@@ -433,7 +442,7 @@ mod tests { | |||
433 | )?, | 442 | )?, |
434 | res | 443 | res |
435 | ); | 444 | ); |
436 | println!("\x1B[FTesting {file:?} ✓"); | 445 | // println!("\x1B[FTesting {file:?} ✓"); |
437 | } | 446 | } |
438 | 447 | ||
439 | remove_dir_all("./backup-test-dir")?; | 448 | remove_dir_all("./backup-test-dir")?; |