Move deduplication tests out to a separate test suite

This commit is contained in:
Cyryl Płotnicki 2020-11-28 14:23:21 +00:00
parent 3ad21574a4
commit 5728645add
2 changed files with 27 additions and 23 deletions

View file

@ -0,0 +1,27 @@
use tempfile::tempdir;
use bakare::repository::Repository;
use bakare::test::{assertions::*, source::TestSource};
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);
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);
assert_restored_file_contents(repository_path, &source.file_path("1"), &contents).unwrap();
assert_restored_file_contents(repository_path, &source.file_path("2"), &contents).unwrap();
}
}

View file

@ -5,8 +5,6 @@ use bakare::backup;
use bakare::repository::Repository; use bakare::repository::Repository;
use bakare::test::{assertions::*, source::TestSource}; use bakare::test::{assertions::*, source::TestSource};
use proptest::prelude::*;
#[test] #[test]
fn restore_multiple_files() -> Result<()> { fn restore_multiple_files() -> Result<()> {
let source = TestSource::new().unwrap(); let source = TestSource::new().unwrap();
@ -81,27 +79,6 @@ fn newer_version_should_be_greater_than_earlier_version() -> Result<()> {
Ok(()) Ok(())
} }
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);
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);
assert_restored_file_contents(repository_path, &source.file_path("1"), &contents).unwrap();
assert_restored_file_contents(repository_path, &source.file_path("2"), &contents).unwrap();
}
}
#[test] #[test]
fn restore_latest_version_by_default() -> Result<()> { fn restore_latest_version_by_default() -> Result<()> {
let source = TestSource::new().unwrap(); let source = TestSource::new().unwrap();