mirror of
https://github.com/qwjyh/xdbm
synced 2024-11-24 07:31:05 +09:00
add test for backup add/done with single device
This works on Windows. It still needs git config to perform commit.
This commit is contained in:
parent
bac829c1f1
commit
1794b8b409
2 changed files with 81 additions and 5 deletions
|
@ -28,9 +28,9 @@ to manage backups on several storages mounted on multiple devices with a single
|
||||||
- [x] reorganize cmd option for storage
|
- [x] reorganize cmd option for storage
|
||||||
- [x] use subcommand
|
- [x] use subcommand
|
||||||
- [ ] backup subcommands
|
- [ ] backup subcommands
|
||||||
- [ ] backup add
|
- [x] backup add
|
||||||
- [ ] test for backup add
|
- [x] test for backup add
|
||||||
- [ ] backup list
|
- [x] backup list
|
||||||
- [x] status printing
|
- [x] status printing
|
||||||
- [x] backup done
|
- [x] backup done
|
||||||
- [ ] fancy display
|
- [ ] fancy display
|
||||||
|
|
80
tests/cli.rs
80
tests/cli.rs
|
@ -1,4 +1,4 @@
|
||||||
mod cmd_init {
|
mod integrated_test {
|
||||||
use std::fs::DirBuilder;
|
use std::fs::DirBuilder;
|
||||||
|
|
||||||
use anyhow::{Ok, Result};
|
use anyhow::{Ok, Result};
|
||||||
|
@ -8,8 +8,9 @@ mod cmd_init {
|
||||||
use predicates::prelude::predicate;
|
use predicates::prelude::predicate;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn init_with_tmpdir() -> Result<()> {
|
fn single_device() -> Result<()> {
|
||||||
let config_dir = assert_fs::TempDir::new()?;
|
let config_dir = assert_fs::TempDir::new()?;
|
||||||
|
// init
|
||||||
let mut cmd = Command::cargo_bin("xdbm")?;
|
let mut cmd = Command::cargo_bin("xdbm")?;
|
||||||
cmd.arg("-c")
|
cmd.arg("-c")
|
||||||
.arg(config_dir.path())
|
.arg(config_dir.path())
|
||||||
|
@ -20,6 +21,81 @@ mod cmd_init {
|
||||||
std::fs::read_to_string(config_dir.path().join("devname"))?,
|
std::fs::read_to_string(config_dir.path().join("devname"))?,
|
||||||
"testdev\n"
|
"testdev\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// storage add
|
||||||
|
let storage = assert_fs::TempDir::new()?;
|
||||||
|
Command::cargo_bin("xdbm")?
|
||||||
|
.arg("-c")
|
||||||
|
.arg(config_dir.path())
|
||||||
|
.arg("storage")
|
||||||
|
.arg("add")
|
||||||
|
.arg("online")
|
||||||
|
.arg("--provider")
|
||||||
|
.arg("sample_provider")
|
||||||
|
.arg("--capacity")
|
||||||
|
.arg("1000000000000")
|
||||||
|
.arg("--alias")
|
||||||
|
.arg("alias")
|
||||||
|
.arg("online_storage")
|
||||||
|
.arg(storage.path())
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
// storage list
|
||||||
|
Command::cargo_bin("xdbm")?
|
||||||
|
.arg("-c")
|
||||||
|
.arg(config_dir.path())
|
||||||
|
.arg("storage")
|
||||||
|
.arg("list")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("online_storage"));
|
||||||
|
|
||||||
|
// backup add
|
||||||
|
let target_from = storage.join("foo/bar");
|
||||||
|
let target_to = storage.join("aaa/bbb/ccc");
|
||||||
|
DirBuilder::new()
|
||||||
|
.recursive(true)
|
||||||
|
.create(target_from.clone())?;
|
||||||
|
DirBuilder::new()
|
||||||
|
.recursive(true)
|
||||||
|
.create(target_to.clone())?;
|
||||||
|
Command::cargo_bin("xdbm")?
|
||||||
|
.arg("-c")
|
||||||
|
.arg(config_dir.path())
|
||||||
|
.arg("backup")
|
||||||
|
.arg("add")
|
||||||
|
.arg("--src")
|
||||||
|
.arg(target_from)
|
||||||
|
.arg("--dest")
|
||||||
|
.arg(target_to)
|
||||||
|
.arg("sample_backup")
|
||||||
|
.arg("external")
|
||||||
|
.arg("rsync")
|
||||||
|
.arg("with some note")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
|
// backup list
|
||||||
|
Command::cargo_bin("xdbm")?
|
||||||
|
.arg("-c")
|
||||||
|
.arg(config_dir.path())
|
||||||
|
.arg("backup")
|
||||||
|
.arg("list")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("sample_backup"));
|
||||||
|
|
||||||
|
Command::cargo_bin("xdbm")?
|
||||||
|
.arg("-c")
|
||||||
|
.arg(config_dir.path())
|
||||||
|
.arg("backup")
|
||||||
|
.arg("done")
|
||||||
|
.arg("sample_backup")
|
||||||
|
.arg("0")
|
||||||
|
.assert()
|
||||||
|
.success();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue