2020-11-28 14:29:23 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
mod must {
|
|
|
|
use tempfile::tempdir;
|
2020-11-28 14:23:21 +00:00
|
|
|
|
2020-11-28 14:29:23 +00:00
|
|
|
use bakare::repository::Repository;
|
|
|
|
use bakare::test::{assertions::*, source::TestSource};
|
2020-11-28 14:23:21 +00:00
|
|
|
|
2020-11-28 14:29:23 +00:00
|
|
|
use proptest::prelude::*;
|
|
|
|
proptest! {
|
|
|
|
#[test]
|
|
|
|
fn store_duplicated_files_just_once(contents in any::<[u8;3]>()) {
|
|
|
|
let source = TestSource::new().unwrap();
|
|
|
|
let repository_path = &tempdir().unwrap().into_path();
|
|
|
|
Repository::init(repository_path).unwrap();
|
|
|
|
assert_eq!(data_weight(&repository_path).unwrap(), 0);
|
2020-11-28 14:23:21 +00:00
|
|
|
|
2020-11-28 14:29:23 +00:00
|
|
|
backup_file_with_byte_contents(&source, &repository_path, "1", &contents).unwrap();
|
|
|
|
let first_weight = data_weight(&repository_path).unwrap();
|
|
|
|
assert!(first_weight > 0);
|
2020-11-28 14:23:21 +00:00
|
|
|
|
2020-11-28 14:29:23 +00:00
|
|
|
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-11-28 14:23:21 +00:00
|
|
|
|
2020-11-28 14:29:23 +00:00
|
|
|
assert_restored_file_contents(repository_path, &source.file_path("1"), &contents).unwrap();
|
|
|
|
assert_restored_file_contents(repository_path, &source.file_path("2"), &contents).unwrap();
|
|
|
|
}
|
2020-11-28 14:23:21 +00:00
|
|
|
}
|
|
|
|
}
|