From 5728645addee49a52fdd1eab4e1bca8b26191a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Sat, 28 Nov 2020 14:23:21 +0000 Subject: [PATCH] Move deduplication tests out to a separate test suite --- tests/deduplication_tests.rs | 27 +++++++++++++++++++++++++++ tests/system_tests.rs | 23 ----------------------- 2 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 tests/deduplication_tests.rs diff --git a/tests/deduplication_tests.rs b/tests/deduplication_tests.rs new file mode 100644 index 0000000..720e4ff --- /dev/null +++ b/tests/deduplication_tests.rs @@ -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(); + } +} diff --git a/tests/system_tests.rs b/tests/system_tests.rs index 71c5c2f..5131acb 100644 --- a/tests/system_tests.rs +++ b/tests/system_tests.rs @@ -5,8 +5,6 @@ use bakare::backup; use bakare::repository::Repository; use bakare::test::{assertions::*, source::TestSource}; -use proptest::prelude::*; - #[test] fn restore_multiple_files() -> Result<()> { let source = TestSource::new().unwrap(); @@ -81,27 +79,6 @@ fn newer_version_should_be_greater_than_earlier_version() -> Result<()> { 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] fn restore_latest_version_by_default() -> Result<()> { let source = TestSource::new().unwrap();