2018-09-02 11:13:37 +01:00
|
|
|
extern crate crypto;
|
2018-09-01 09:44:13 +01:00
|
|
|
extern crate tempfile;
|
2018-09-02 11:13:37 +01:00
|
|
|
extern crate dir_diff;
|
|
|
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
struct BackupEngine;
|
|
|
|
impl BackupEngine {
|
|
|
|
fn new(path: &Path) -> Self {
|
|
|
|
BackupEngine {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn backup(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct RestoreEngine;
|
|
|
|
impl RestoreEngine {
|
|
|
|
fn new(path: &Path) -> Self {
|
|
|
|
RestoreEngine {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn restore(&self) {}
|
|
|
|
}
|
2018-08-17 17:58:18 +01:00
|
|
|
|
2018-09-01 09:44:13 +01:00
|
|
|
mod rustback {
|
2018-08-17 17:58:18 +01:00
|
|
|
|
2018-08-18 18:39:40 +01:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod should {
|
|
|
|
|
2018-09-01 09:44:13 +01:00
|
|
|
use super::*;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::io::Error;
|
2018-09-02 11:13:37 +01:00
|
|
|
use std::io::{self, Write};
|
|
|
|
use tempfile::tempdir;
|
|
|
|
use tempfile::tempfile_in;
|
|
|
|
use tempfile::TempDir;
|
|
|
|
use dir_diff::is_different;
|
2018-09-01 09:44:13 +01:00
|
|
|
|
2018-08-18 18:39:40 +01:00
|
|
|
#[test]
|
2018-09-01 09:44:13 +01:00
|
|
|
fn be_able_to_restore_backed_up_files() -> Result<(), Error> {
|
2018-09-02 11:13:37 +01:00
|
|
|
let source = tempdir()?;
|
|
|
|
File::create(source.path().join("first"))?;
|
|
|
|
File::create(source.path().join("second"))?;
|
|
|
|
File::create(source.path().join("third"))?;
|
2018-09-01 09:44:13 +01:00
|
|
|
|
2018-09-02 11:13:37 +01:00
|
|
|
let backup_engine = BackupEngine::new(&source.path());
|
|
|
|
backup_engine.backup();
|
2018-09-01 09:44:13 +01:00
|
|
|
|
2018-09-02 11:13:37 +01:00
|
|
|
let destination = tempdir()?;
|
|
|
|
let restore_engine = RestoreEngine::new(&destination.path());
|
|
|
|
restore_engine.restore();
|
2018-09-01 09:44:13 +01:00
|
|
|
|
2018-09-02 11:13:37 +01:00
|
|
|
let is_source_and_destination_different = is_different(&source.path(), &destination.path()).unwrap();
|
|
|
|
assert!(!is_source_and_destination_different);
|
2018-09-01 09:44:13 +01:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
2018-08-18 18:39:40 +01:00
|
|
|
|
2018-09-01 09:44:13 +01:00
|
|
|
}
|
2018-08-18 18:39:40 +01:00
|
|
|
|