mirror of
https://github.com/qwjyh/xdbm
synced 2025-06-26 17:59:20 +09:00
Use git cli in sync subcommand, and make custom implementation optional (#27)
* new: add use_cl option and separate to function * refactor: format * new(sync): add option to use git cli * change(sync)!: now it use git cli by default * lint: remove unnecessary ref * fix(sync): use stderr for log prints * update: CHANGELOG
This commit is contained in:
parent
851c0259a1
commit
e9c1872d79
6 changed files with 110 additions and 30 deletions
40
tests/cli.rs
40
tests/cli.rs
|
@ -5,8 +5,8 @@ mod integrated_test {
|
|||
path,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Context, Ok, Result};
|
||||
use assert_cmd::{assert::OutputAssertExt, Command};
|
||||
use anyhow::{Context, Ok, Result, anyhow};
|
||||
use assert_cmd::{Command, assert::OutputAssertExt};
|
||||
use git2::Repository;
|
||||
use log::{debug, trace};
|
||||
use predicates::{boolean::PredicateBooleanExt, prelude::predicate};
|
||||
|
@ -73,13 +73,22 @@ mod integrated_test {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn run_sync_cmd(config_dir: &path::Path) -> Result<()> {
|
||||
Command::cargo_bin("xdbm")?
|
||||
.arg("-c")
|
||||
.arg(config_dir)
|
||||
.args(["sync", "-vvvv"])
|
||||
.assert()
|
||||
.success();
|
||||
fn run_sync_cmd(config_dir: &path::Path, use_cl: bool) -> Result<()> {
|
||||
if use_cl {
|
||||
Command::cargo_bin("xdbm")?
|
||||
.arg("-c")
|
||||
.arg(config_dir)
|
||||
.args(["sync", "-vvvv"])
|
||||
.assert()
|
||||
.success();
|
||||
} else {
|
||||
Command::cargo_bin("xdbm")?
|
||||
.arg("-c")
|
||||
.arg(config_dir)
|
||||
.args(["sync", "-vvvv", "-u"])
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -329,6 +338,7 @@ mod integrated_test {
|
|||
.arg(config_dir_2.path())
|
||||
.arg("sync")
|
||||
.arg("-vvvv")
|
||||
.arg("-u")
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(predicate::str::contains("successfully pushed"));
|
||||
|
@ -391,8 +401,8 @@ mod integrated_test {
|
|||
std::fs::read_to_string(config_dir_1.join("storages.yml"))?.contains("parent: gdrive1")
|
||||
);
|
||||
|
||||
run_sync_cmd(&config_dir_1)?;
|
||||
run_sync_cmd(&config_dir_2)?;
|
||||
run_sync_cmd(&config_dir_1, false)?;
|
||||
run_sync_cmd(&config_dir_2, false)?;
|
||||
|
||||
// bind
|
||||
//
|
||||
|
@ -606,8 +616,8 @@ mod integrated_test {
|
|||
.and(predicate::str::contains("foodoc").not()),
|
||||
);
|
||||
|
||||
run_sync_cmd(&config_dir_2)?;
|
||||
run_sync_cmd(&config_dir_1)?;
|
||||
run_sync_cmd(&config_dir_2, true)?;
|
||||
run_sync_cmd(&config_dir_1, true)?;
|
||||
|
||||
// bind
|
||||
//
|
||||
|
@ -722,8 +732,8 @@ mod integrated_test {
|
|||
.assert()
|
||||
.success();
|
||||
|
||||
run_sync_cmd(&config_dir_1)?;
|
||||
run_sync_cmd(&config_dir_2)?;
|
||||
run_sync_cmd(&config_dir_1, false)?;
|
||||
run_sync_cmd(&config_dir_2, false)?;
|
||||
|
||||
// backup add
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue