Skip to content

Commit fe61d11

Browse files
committed
test: some hardlinks without deduplication
1 parent 7a259b0 commit fe61d11

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/deduplicate_hardlinks.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,3 +642,62 @@ fn hardlinks_and_non_hardlinks_with_deduplication() {
642642
expected_hardlinks_summary.trim_end(),
643643
);
644644
}
645+
646+
#[test]
647+
fn hardlinks_and_non_hardlinks_without_deduplication() {
648+
let files_per_branch = 2 * 4;
649+
let workspace =
650+
SampleWorkspace::complex_tree_with_shared_and_unique_files(files_per_branch, 100_000);
651+
652+
let tree = Command::new(PDU)
653+
.with_current_dir(&workspace)
654+
.with_arg("--min-ratio=0")
655+
.with_arg("--quantity=apparent-size")
656+
.with_arg("--json-output")
657+
.with_arg("some-hardlinks")
658+
.pipe(stdio)
659+
.output()
660+
.expect("spawn command")
661+
.pipe(stdout_text)
662+
.pipe_as_ref(serde_json::from_str::<JsonData>)
663+
.expect("parse stdout as JsonData")
664+
.body
665+
.pipe(JsonTree::<Bytes>::try_from)
666+
.expect("get tree of bytes");
667+
668+
let file_size = workspace
669+
.join("some-hardlinks/file-0.txt")
670+
.pipe_as_ref(read_apparent_size)
671+
.pipe(Bytes::new);
672+
673+
let inode_size = |path: &str| {
674+
workspace
675+
.join(path)
676+
.pipe_as_ref(read_apparent_size)
677+
.pipe(Bytes::new)
678+
};
679+
680+
let actual_size = tree.size;
681+
let expected_size = [
682+
inode_size("some-hardlinks"),
683+
file_size * files_per_branch, // file-{index}.txt
684+
file_size * (2usize + 1usize), // link0-file0.txt, link1-file0.txt, link0-file1.txt
685+
]
686+
.into_iter()
687+
.sum();
688+
assert_eq!(actual_size, expected_size);
689+
690+
assert_eq!(tree.shared.details, None);
691+
assert_eq!(tree.shared.summary, None);
692+
693+
let visualization = Command::new(PDU)
694+
.with_current_dir(&workspace)
695+
.with_arg("--quantity=apparent-size")
696+
.with_arg("some-hardlinks")
697+
.pipe(stdio)
698+
.output()
699+
.expect("spawn command")
700+
.pipe(stdout_text);
701+
eprintln!("STDOUT:\n{visualization}");
702+
assert!(!visualization.contains("Hardlinks detected!"));
703+
}

0 commit comments

Comments
 (0)