do not use proptest for the repo unittests as it was quite slow

This commit is contained in:
Cyryl Płotnicki 2020-11-28 14:20:53 +00:00
parent 981283aede
commit 3ad21574a4

View file

@ -173,26 +173,26 @@ impl<'a> Repository<'a> {
mod must { mod must {
use super::Repository; use super::Repository;
use crate::test::source::TestSource; use crate::test::source::TestSource;
use proptest::prelude::*; use anyhow::Result;
use tempfile::tempdir; use tempfile::tempdir;
proptest! { #[test]
fn have_size_equal_to_sum_of_sizes_of_backed_up_files() -> Result<()> {
let file_size1 = 13;
let file_size2 = 27;
let source = TestSource::new()?;
let repository_path = tempdir()?.into_path();
Repository::init(&repository_path)?;
#[test] let mut backup_repository = Repository::open(&repository_path)?;
fn have_size_equal_to_sum_of_sizes_of_backed_up_files(file_size1 in 0u64..128, file_size2 in 0u64..128) { source.write_random_bytes_to_file("file1", file_size1)?;
let source = TestSource::new().unwrap(); backup_repository.store(&source.file_path("file1"))?;
let repository_path = tempdir().unwrap().into_path();
Repository::init(&repository_path).unwrap();
let mut backup_repository = Repository::open(&repository_path).unwrap(); source.write_random_bytes_to_file("file2", file_size2)?;
source.write_random_bytes_to_file("file1", file_size1)?;
backup_repository.store(&source.file_path("file1")).unwrap();
source.write_random_bytes_to_file("file2", file_size2)?; backup_repository.store(&source.file_path("file2"))?;
backup_repository.store(&source.file_path("file2")).unwrap();
assert_eq!(file_size1 + file_size2, backup_repository.data_weight().unwrap());
}
assert_eq!(file_size1 + file_size2, backup_repository.data_weight()?);
Ok(())
} }
} }