2020-08-05 12:54:52 +05:30
|
|
|
use anyhow::Result;
|
|
|
|
use thinp::version::TOOLS_VERSION;
|
|
|
|
|
|
|
|
mod common;
|
|
|
|
use common::*;
|
2020-08-07 19:00:00 +05:30
|
|
|
use common::test_dir::*;
|
2020-08-05 12:54:52 +05:30
|
|
|
|
|
|
|
//------------------------------------------
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn accepts_v() -> Result<()> {
|
|
|
|
let stdout = thin_delta!("-V").read()?;
|
|
|
|
assert_eq!(stdout, TOOLS_VERSION);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn accepts_version() -> Result<()> {
|
|
|
|
let stdout = thin_delta!("--version").read()?;
|
|
|
|
assert_eq!(stdout, TOOLS_VERSION);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2020-11-26 08:05:40 +05:30
|
|
|
const USAGE: &str = "Usage: thin_delta [options] <device or file>\nOptions:\n {--thin1, --snap1, --root1}\n {--thin2, --snap2, --root2}\n {-m, --metadata-snap} [block#]\n {--verbose}\n {-h|--help}\n {-V|--version}";
|
2020-08-05 12:54:52 +05:30
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn accepts_h() -> Result<()> {
|
|
|
|
let stdout = thin_delta!("-h").read()?;
|
|
|
|
assert_eq!(stdout, USAGE);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn accepts_help() -> Result<()> {
|
|
|
|
let stdout = thin_delta!("--help").read()?;
|
|
|
|
assert_eq!(stdout, USAGE);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn rejects_bad_option() -> Result<()> {
|
|
|
|
let stderr = run_fail(thin_delta!("--hedgehogs-only"))?;
|
|
|
|
assert!(stderr.contains("unrecognized option \'--hedgehogs-only\'"));
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn snap1_unspecified() -> Result<()> {
|
|
|
|
let mut td = TestDir::new()?;
|
|
|
|
let md = mk_valid_md(&mut td)?;
|
|
|
|
let stderr = run_fail(thin_delta!("--snap2", "45", &md))?;
|
2020-11-26 08:05:40 +05:30
|
|
|
assert!(stderr.contains("--snap1 or --root1 not specified"));
|
2020-08-05 12:54:52 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn snap2_unspecified() -> Result<()> {
|
|
|
|
let mut td = TestDir::new()?;
|
|
|
|
let md = mk_valid_md(&mut td)?;
|
|
|
|
let stderr = run_fail(thin_delta!("--snap1", "45", &md))?;
|
2020-11-26 08:05:40 +05:30
|
|
|
assert!(stderr.contains("--snap2 or --root2 not specified"));
|
2020-08-05 12:54:52 +05:30
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn dev_unspecified() -> Result<()> {
|
|
|
|
let stderr = run_fail(thin_delta!("--snap1", "45", "--snap2", "46"))?;
|
|
|
|
assert!(stderr.contains("No input device provided"));
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|