Skip to content

Commit

Permalink
test: add more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
KSXGitHub committed Dec 1, 2024
1 parent 8955f37 commit 2beb762
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/app/sub/hdd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,28 +115,51 @@ mod tests {
Disk::new(DiskKind::HDD, "/mnt/data/repo"),
];

for (paths, in_hdd) in [
let cases: &[(&[PathBuf], bool)] = &[
(&[], false),
(&[PathBuf::from("/")], false),
(&[PathBuf::from("/home")], true),
(&[PathBuf::from("/mnt")], false),
(&[PathBuf::from("/mnt/repo")], false),
(&[PathBuf::from("/mnt/data")], true),
(&[PathBuf::from("/mnt/data/repo")], true),
(&[PathBuf::from("/etc/fstab")], false),
(&[PathBuf::from("/home/usr/file")], true),
(&[PathBuf::from("/home/data/repo/test")], true),
(&[PathBuf::from("/usr/share")], false),
(&[PathBuf::from("/mnt/repo/test")], false),
(
[
&[
PathBuf::from("/etc/fstab"),
PathBuf::from("/home/user/file"),
],
true,
),
(
[
&[
PathBuf::from("/mnt/data/file"),
PathBuf::from("/mnt/data/repo/test"),
],
true,
),
(
[PathBuf::from("/usr/share"), PathBuf::from("/mnt/repo/test")],
&[PathBuf::from("/usr/share"), PathBuf::from("/mnt/repo/test")],
false,
),
] {
(
&[
PathBuf::from("/etc/fstab"),
PathBuf::from("/home/user"),
PathBuf::from("/mnt/data"),
PathBuf::from("/usr/share"),
],
true,
),
];

for (paths, in_hdd) in cases {
println!("CASE: {paths:?} → {in_hdd:?}");
assert_eq!(any_path_is_in_hdd::<MockedApi>(&paths, disks), in_hdd);
assert_eq!(any_path_is_in_hdd::<MockedApi>(paths, disks), *in_hdd);
}
}
}

0 comments on commit 2beb762

Please sign in to comment.