mirror of
https://github.com/qwjyh/xdbm
synced 2025-04-21 04:05:49 +09:00
Compare commits
No commits in common. "6e1619aa18f9fc40d5b9b7ed6ee9a1f9856f4444" and "3b7e2387bdee8579bc802172c0b545342f43a9c7" have entirely different histories.
6e1619aa18
...
3b7e2387bd
5 changed files with 13 additions and 53 deletions
|
@ -57,7 +57,9 @@ pub(crate) enum Commands {
|
||||||
Check {},
|
Check {},
|
||||||
|
|
||||||
/// Generate completion script.
|
/// Generate completion script.
|
||||||
Completion { shell: clap_complete::Shell },
|
Completion {
|
||||||
|
shell: clap_complete::Shell,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
|
|
|
@ -216,7 +216,7 @@ fn write_backups_list(
|
||||||
None => {
|
None => {
|
||||||
let style = Style::new().red();
|
let style = Style::new().red();
|
||||||
(style.apply_to("---".to_string()), style)
|
(style.apply_to("---".to_string()), style)
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
if !longprint {
|
if !longprint {
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Manipulates storages.
|
//! Manipulates storages.
|
||||||
|
|
||||||
|
use console::{style, Style, StyledObject};
|
||||||
use crate::devices;
|
use crate::devices;
|
||||||
use crate::storages::{
|
use crate::storages::{
|
||||||
directory::Directory, online_storage::OnlineStorage,
|
directory::Directory, online_storage::OnlineStorage,
|
||||||
|
@ -7,7 +8,6 @@ use crate::storages::{
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
use console::{style, Style, StyledObject};
|
|
||||||
use core::panic;
|
use core::panic;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{collections::BTreeMap, fmt, fs, io, path};
|
use std::{collections::BTreeMap, fmt, fs, io, path};
|
||||||
|
|
|
@ -180,7 +180,9 @@ mod test {
|
||||||
local_infos,
|
local_infos,
|
||||||
);
|
);
|
||||||
let mut storages = Storages::new();
|
let mut storages = Storages::new();
|
||||||
storages.add(storages::Storage::Physical(physical)).unwrap();
|
storages
|
||||||
|
.add(storages::Storage::Physical(physical))
|
||||||
|
.unwrap();
|
||||||
storages.add(Storage::SubDirectory(directory)).unwrap();
|
storages.add(Storage::SubDirectory(directory)).unwrap();
|
||||||
// assert_eq!(directory.name(), "test_name");
|
// assert_eq!(directory.name(), "test_name");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
54
tests/cli.rs
54
tests/cli.rs
|
@ -5,11 +5,11 @@ mod integrated_test {
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Ok, Result};
|
use anyhow::{Context, Ok, Result};
|
||||||
use assert_cmd::{assert::OutputAssertExt, cargo::CommandCargoExt, Command};
|
use assert_cmd::{assert::OutputAssertExt, Command};
|
||||||
use dirs::home_dir;
|
use dirs::home_dir;
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
use log::trace;
|
use log::trace;
|
||||||
use predicates::{boolean::PredicateBooleanExt, prelude::predicate};
|
use predicates::prelude::predicate;
|
||||||
|
|
||||||
/// Setup global gitconfig if it doesn't exist.
|
/// Setup global gitconfig if it doesn't exist.
|
||||||
///
|
///
|
||||||
|
@ -157,14 +157,7 @@ mod integrated_test {
|
||||||
// set up upstream branch
|
// set up upstream branch
|
||||||
let (mut repo_1_branch, _branch_type) = repo_1.branches(None)?.next().unwrap()?;
|
let (mut repo_1_branch, _branch_type) = repo_1.branches(None)?.next().unwrap()?;
|
||||||
println!("head {}", repo_1.head().unwrap().name().unwrap());
|
println!("head {}", repo_1.head().unwrap().name().unwrap());
|
||||||
repo_1_branch.set_upstream(Some(
|
repo_1_branch.set_upstream(Some(format!("{}/{}", upstream_name, repo_1_branch.name().unwrap().unwrap()).as_str()))?;
|
||||||
format!(
|
|
||||||
"{}/{}",
|
|
||||||
upstream_name,
|
|
||||||
repo_1_branch.name().unwrap().unwrap()
|
|
||||||
)
|
|
||||||
.as_str(),
|
|
||||||
))?;
|
|
||||||
|
|
||||||
// 2nd device
|
// 2nd device
|
||||||
let config_dir_2 = assert_fs::TempDir::new()?;
|
let config_dir_2 = assert_fs::TempDir::new()?;
|
||||||
|
@ -238,14 +231,7 @@ mod integrated_test {
|
||||||
println!("{:?}", bare_repo_dir.read_dir()?);
|
println!("{:?}", bare_repo_dir.read_dir()?);
|
||||||
// set up upstream branch
|
// set up upstream branch
|
||||||
let (mut repo_1_branch, _branch_type) = repo_1.branches(None)?.next().unwrap()?;
|
let (mut repo_1_branch, _branch_type) = repo_1.branches(None)?.next().unwrap()?;
|
||||||
repo_1_branch.set_upstream(Some(
|
repo_1_branch.set_upstream(Some(format!("{}/{}", upstream_name, repo_1_branch.name().unwrap().unwrap()).as_str()))?;
|
||||||
format!(
|
|
||||||
"{}/{}",
|
|
||||||
upstream_name,
|
|
||||||
repo_1_branch.name().unwrap().unwrap()
|
|
||||||
)
|
|
||||||
.as_str(),
|
|
||||||
))?;
|
|
||||||
|
|
||||||
// 2nd device
|
// 2nd device
|
||||||
let config_dir_2 = assert_fs::TempDir::new()?;
|
let config_dir_2 = assert_fs::TempDir::new()?;
|
||||||
|
@ -372,7 +358,6 @@ mod integrated_test {
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
// storage list
|
|
||||||
Command::cargo_bin("xdbm")?
|
Command::cargo_bin("xdbm")?
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(config_dir_2.path())
|
.arg(config_dir_2.path())
|
||||||
|
@ -380,9 +365,7 @@ mod integrated_test {
|
||||||
.arg("list")
|
.arg("list")
|
||||||
.arg("-l")
|
.arg("-l")
|
||||||
.assert()
|
.assert()
|
||||||
.success()
|
.success();
|
||||||
.stdout(predicate::str::contains("gdrive_docs").and(predicate::str::contains("nas")));
|
|
||||||
|
|
||||||
// backup add
|
// backup add
|
||||||
let backup_src = &sample_storage_2.join("foo").join("bar");
|
let backup_src = &sample_storage_2.join("foo").join("bar");
|
||||||
DirBuilder::new().recursive(true).create(backup_src)?;
|
DirBuilder::new().recursive(true).create(backup_src)?;
|
||||||
|
@ -404,7 +387,6 @@ mod integrated_test {
|
||||||
.assert()
|
.assert()
|
||||||
.success();
|
.success();
|
||||||
|
|
||||||
// backup add but with existing name
|
|
||||||
Command::cargo_bin("xdbm")?
|
Command::cargo_bin("xdbm")?
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(config_dir_2.path())
|
.arg(config_dir_2.path())
|
||||||
|
@ -422,32 +404,6 @@ mod integrated_test {
|
||||||
.failure()
|
.failure()
|
||||||
.stderr(predicate::str::contains("already"));
|
.stderr(predicate::str::contains("already"));
|
||||||
|
|
||||||
// backup list
|
|
||||||
Command::cargo_bin("xdbm")?
|
|
||||||
.arg("-c")
|
|
||||||
.arg(config_dir_2.path())
|
|
||||||
.arg("backup")
|
|
||||||
.arg("list")
|
|
||||||
.assert()
|
|
||||||
.success()
|
|
||||||
.stdout(
|
|
||||||
predicate::str::contains("foodoc")
|
|
||||||
.and(predicate::str::contains("nas"))
|
|
||||||
.and(predicate::str::contains("gdrive_docs"))
|
|
||||||
.and(predicate::str::contains("---")),
|
|
||||||
);
|
|
||||||
|
|
||||||
// backup done
|
|
||||||
Command::cargo_bin("xdbm")?
|
|
||||||
.arg("-c")
|
|
||||||
.arg(config_dir_2.path())
|
|
||||||
.arg("backup")
|
|
||||||
.arg("done")
|
|
||||||
.arg("foodoc")
|
|
||||||
.arg("0")
|
|
||||||
.assert()
|
|
||||||
.success();
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue