Introduce concept of a repository

This commit is contained in:
Cyryl Płotnicki 2018-09-02 14:18:58 +01:00
parent 2fc1a2fc9c
commit 4f7fef37d2

View file

@ -6,7 +6,7 @@ use std::path::Path;
struct BackupEngine; struct BackupEngine;
impl BackupEngine { impl BackupEngine {
fn new(path: &Path) -> Self { fn new(source_path: &Path, repository_path: &Path) -> Self {
BackupEngine {} BackupEngine {}
} }
@ -15,7 +15,7 @@ impl BackupEngine {
struct RestoreEngine; struct RestoreEngine;
impl RestoreEngine { impl RestoreEngine {
fn new(path: &Path) -> Self { fn new(repository_path: &Path, target_path: &Path) -> Self {
RestoreEngine {} RestoreEngine {}
} }
@ -47,14 +47,15 @@ mod rustback {
File::create(source.path().join("second"))?.write_all("some contents".as_bytes())?; File::create(source.path().join("second"))?.write_all("some contents".as_bytes())?;
File::create(source.path().join("third"))?.write_all("some other contents".as_bytes())?; File::create(source.path().join("third"))?.write_all("some other contents".as_bytes())?;
let backup_engine = BackupEngine::new(&source.path()); let repository = tempdir()?;
let backup_engine = BackupEngine::new(&source.path(), &repository.path());
backup_engine.backup(); backup_engine.backup();
let destination = tempdir()?; let restore_target = tempdir()?;
let restore_engine = RestoreEngine::new(&destination.path()); let restore_engine = RestoreEngine::new(&repository.path(), &restore_target.path());
restore_engine.restore(); restore_engine.restore();
let is_source_and_destination_different = is_different(&source.path(), &destination.path()).unwrap(); let is_source_and_destination_different = is_different(&source.path(), &restore_target.path()).unwrap();
assert!(!is_source_and_destination_different); assert!(!is_source_and_destination_different);
Ok(()) Ok(())
} }