fix: update tests to handle Skipped paths
parent
6fa4ff0168
commit
9061d32c89
|
@ -310,7 +310,7 @@ impl FsStore {
|
|||
panic!("File {} too large?!", path.display());
|
||||
}
|
||||
if size == 0 {
|
||||
return Ok(UpdatePathOutcome::Skipped(path.clone()));
|
||||
return Ok(UpdatePathOutcome::Skipped(path));
|
||||
}
|
||||
let mtime = metadata
|
||||
.modified()
|
||||
|
@ -828,8 +828,8 @@ mod test {
|
|||
let mut tmp_file = File::create(file_path).unwrap();
|
||||
writeln!(tmp_file, "Hello, World!").unwrap();
|
||||
|
||||
let file_path = temp_dir.path().join("empty");
|
||||
File::create(file_path).unwrap();
|
||||
let empty_path = temp_dir.path().join("empty");
|
||||
File::create(&empty_path).unwrap();
|
||||
|
||||
// Initialize database
|
||||
let open_result = UpEndDatabase::open(&temp_dir, true).unwrap();
|
||||
|
@ -843,9 +843,11 @@ mod test {
|
|||
assert!(rescan_result.is_ok());
|
||||
let rescan_result = rescan_result.unwrap();
|
||||
assert_eq!(rescan_result.len(), 3);
|
||||
rescan_result
|
||||
.into_iter()
|
||||
.for_each(|outcome| assert!(matches!(outcome, UpdatePathOutcome::Added(_))));
|
||||
rescan_result.into_iter().for_each(|outcome| match outcome {
|
||||
UpdatePathOutcome::Added(_) => assert!(true),
|
||||
UpdatePathOutcome::Skipped(path) => assert_eq!(path, empty_path),
|
||||
outcome => panic!("Unexpected outcome: {:?}", outcome),
|
||||
});
|
||||
|
||||
// Modification-less rescan
|
||||
let job = job_container.add_job("RESCAN", "TEST JOB").unwrap();
|
||||
|
@ -854,9 +856,12 @@ mod test {
|
|||
assert!(rescan_result.is_ok());
|
||||
let rescan_result = rescan_result.unwrap();
|
||||
assert_eq!(rescan_result.len(), 3);
|
||||
rescan_result
|
||||
.into_iter()
|
||||
.for_each(|outcome| assert!(matches!(outcome, UpdatePathOutcome::Unchanged(_))));
|
||||
rescan_result.into_iter().for_each(|outcome| {
|
||||
assert!(matches!(
|
||||
outcome,
|
||||
UpdatePathOutcome::Unchanged(_) | UpdatePathOutcome::Skipped(_)
|
||||
))
|
||||
});
|
||||
|
||||
// Remove a file
|
||||
std::fs::remove_file(temp_dir.path().join("hello-world.txt")).unwrap();
|
||||
|
@ -868,12 +873,19 @@ mod test {
|
|||
let rescan_result = rescan_result.unwrap();
|
||||
assert_eq!(rescan_result.len(), 3);
|
||||
assert_eq!(
|
||||
2,
|
||||
1,
|
||||
rescan_result
|
||||
.iter()
|
||||
.filter(|upo| matches!(upo, UpdatePathOutcome::Unchanged(_)))
|
||||
.count()
|
||||
);
|
||||
assert_eq!(
|
||||
1,
|
||||
rescan_result
|
||||
.iter()
|
||||
.filter(|upo| matches!(upo, UpdatePathOutcome::Skipped(_)))
|
||||
.count()
|
||||
);
|
||||
assert_eq!(
|
||||
1,
|
||||
rescan_result
|
||||
|
|
Loading…
Reference in New Issue