use std::path::Path;
use std::process::Command;
use assert_cmd::prelude::*;
use tempfile::TempDir;
fn mnem(repo: &Path, args: &[&str]) -> Command {
let mut cmd = Command::cargo_bin("mnem").expect("built mnem binary");
cmd.current_dir(repo);
cmd.arg("-R").arg(repo);
for a in args {
cmd.arg(a);
}
cmd
}
#[test]
fn deferred_verbs_surface_in_help() {
let out = Command::cargo_bin("mnem")
.unwrap()
.arg("--help")
.assert()
.success();
let stdout = String::from_utf8_lossy(&out.get_output().stdout).to_string();
for verb in [
"fetch", "push", "pull", "merge", "revert", "fsck", "gc", "branch", "blame", "cat-file",
"remote", "clone",
] {
assert!(
stdout.contains(verb),
"--help must list `{verb}`, got: {stdout}"
);
}
}
#[test]
fn revert_fsck_gc_all_exit_78() {
let dir = TempDir::new().unwrap();
mnem(dir.path(), &["init", dir.path().to_str().unwrap()])
.assert()
.success();
for args in [vec!["revert", "bafk"], vec!["fsck"], vec!["gc"]] {
let out = mnem(dir.path(), &args).assert().failure();
let code = out.get_output().status.code();
assert_eq!(
code,
Some(78),
"verb {args:?} must exit 78 (EX_CONFIG), got {code:?}"
);
}
}