Skip to content

Commit 7a259b0

Browse files
committed
refactor: shorten the code
1 parent 03adc0f commit 7a259b0

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

tests/deduplicate_hardlinks.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use parallel_disk_usage::{
1111
bytes_format::BytesFormat,
1212
data_tree::Reflection,
1313
hardlink::{
14-
hardlink_list::{self, Summary},
14+
hardlink_list::{reflection::ReflectionEntry, Summary},
1515
LinkPathListReflection,
1616
},
1717
inode::InodeNumber,
@@ -100,7 +100,7 @@ fn multiple_hardlinks_to_a_single_file_with_deduplication() {
100100
.iter()
101101
.cloned()
102102
.collect();
103-
let expected_shared_details = [hardlink_list::reflection::ReflectionEntry {
103+
let expected_shared_details = [ReflectionEntry {
104104
ino: file_ino,
105105
size: file_size,
106106
links: 1 + links,
@@ -221,10 +221,7 @@ fn complex_tree_with_shared_and_unique_files_with_deduplication() {
221221

222222
assert_eq!(actual_size, expected_size);
223223

224-
fn starts_with_path(
225-
item: &hardlink_list::reflection::ReflectionEntry<Bytes>,
226-
prefix: &str,
227-
) -> bool {
224+
fn starts_with_path(item: &ReflectionEntry<Bytes>, prefix: &str) -> bool {
228225
item.paths
229226
.0
230227
.iter()
@@ -288,7 +285,7 @@ fn complex_tree_with_shared_and_unique_files_with_deduplication() {
288285
.iter()
289286
.find(|item| starts_with_path(item, "some-hardlinks/file-0.txt"))
290287
.cloned();
291-
let expected = Some(hardlink_list::reflection::ReflectionEntry {
288+
let expected = Some(ReflectionEntry {
292289
ino: workspace
293290
.join("some-hardlinks/file-0.txt")
294291
.pipe_as_ref(read_inode_number)
@@ -317,7 +314,7 @@ fn complex_tree_with_shared_and_unique_files_with_deduplication() {
317314
.iter()
318315
.find(|item| starts_with_path(item, &format!("some-hardlinks/file-{file_index}.txt")))
319316
.cloned();
320-
let expected = Some(hardlink_list::reflection::ReflectionEntry {
317+
let expected = Some(ReflectionEntry {
321318
ino: workspace
322319
.join(format!("some-hardlinks/file-{file_index}.txt"))
323320
.pipe_as_ref(read_inode_number)
@@ -507,38 +504,38 @@ fn hardlinks_and_non_hardlinks_with_deduplication() {
507504
.cloned()
508505
.collect();
509506
let expected_shared_details = [
510-
hardlink_list::reflection::ReflectionEntry {
507+
ReflectionEntry {
511508
ino: file_inode("file-0.txt"),
512509
size: file_size,
513510
links: 3,
514511
paths: shared_paths(&["file-0.txt", "link0-file0.txt", "link1-file0.txt"]),
515512
},
516-
hardlink_list::reflection::ReflectionEntry {
513+
ReflectionEntry {
517514
ino: file_inode("file-1.txt"),
518515
size: file_size,
519516
links: 2,
520517
paths: shared_paths(&["file-1.txt", "link0-file1.txt"]),
521518
},
522519
// ... file-2.txt and file-3.txt don't have hardlinks so they shouldn't appear here ...
523-
hardlink_list::reflection::ReflectionEntry {
520+
ReflectionEntry {
524521
ino: file_inode("file-4.txt"),
525522
size: file_size,
526523
links: 2,
527524
paths: shared_paths(&["file-4.txt"]),
528525
},
529-
hardlink_list::reflection::ReflectionEntry {
526+
ReflectionEntry {
530527
ino: file_inode("file-5.txt"),
531528
size: file_size,
532529
links: 2,
533530
paths: shared_paths(&["file-5.txt"]),
534531
},
535-
hardlink_list::reflection::ReflectionEntry {
532+
ReflectionEntry {
536533
ino: file_inode("file-6.txt"),
537534
size: file_size,
538535
links: 2,
539536
paths: shared_paths(&["file-6.txt"]),
540537
},
541-
hardlink_list::reflection::ReflectionEntry {
538+
ReflectionEntry {
542539
ino: file_inode("file-7.txt"),
543540
size: file_size,
544541
links: 2,

0 commit comments

Comments
 (0)