bakare/tests/deduplication_tests.rs

30 lines
1.2 KiB
Rust
Raw Normal View History

#[cfg(test)]
mod must {
2020-12-25 21:52:40 +00:00
use bakare::test::assertions::in_memory::*;
use bakare::{repository::Repository, test::source::TestSource};
use proptest::prelude::*;
2021-05-16 19:15:07 +01:00
use tempfile::tempdir;
2021-01-30 10:40:32 +00:00
proptest! {
#[test]
fn store_duplicated_files_just_once(contents in any::<[u8;3]>()) {
let source = TestSource::new().unwrap();
2021-05-16 19:15:07 +01:00
let dir = tempdir().unwrap();
let repository_path = dir.path();
2020-12-25 21:52:40 +00:00
Repository::init(&repository_path).unwrap();
assert_eq!(data_weight(&repository_path).unwrap(), 0);
backup_file_with_byte_contents(&source, &repository_path, "1", &contents).unwrap();
let first_weight = data_weight(&repository_path).unwrap();
assert!(first_weight > 0);
backup_file_with_byte_contents(&source, &repository_path, "2", &contents).unwrap();
let second_weight = data_weight(&repository_path).unwrap();
assert_eq!(first_weight, second_weight);
2020-12-25 21:52:40 +00:00
assert_restored_file_contents(&repository_path, &source.file_path("1").unwrap(), &contents).unwrap();
assert_restored_file_contents(&repository_path, &source.file_path("2").unwrap(), &contents).unwrap();
}
}
}