mod common;
#[test]
fn edit_loop_help_flags_all_wired_to_tests() {
let output = common::atomwrite()
.args(["edit-loop", "--help"])
.output()
.expect("run");
assert!(output.status.success());
let help = String::from_utf8_lossy(&output.stdout);
let flags = [
"--allow-sequential-drift",
"--backup",
"--retention",
"--keep-backup",
"--syntax-check",
"--line-ending",
];
for flag in flags {
assert!(
help.contains(flag),
"flag {flag} deve aparecer em edit-loop --help"
);
}
let test_path = std::path::Path::new("tests/cli_v0121_edit_loop.rs");
let test_content = std::fs::read_to_string(test_path).expect("read test file");
for flag in flags {
let kebab = flag.trim_start_matches("--");
let snake = kebab.replace('-', "_");
assert!(
test_content.contains(kebab) || test_content.contains(&snake),
"teste deve referenciar flag {flag} (procura por {kebab} ou {snake})"
);
}
}
#[test]
fn prune_backups_help_flags_all_wired_to_tests() {
let output = common::atomwrite()
.args(["prune-backups", "--help"])
.output()
.expect("run");
assert!(output.status.success());
let help = String::from_utf8_lossy(&output.stdout);
let flags = ["--max-age-secs", "--max-count", "--dry-run"];
for flag in flags {
assert!(help.contains(flag), "flag {flag} deve aparecer em --help");
}
let test_path = std::path::Path::new("tests/cli_v0121_prune_backups.rs");
let test_content = std::fs::read_to_string(test_path).expect("read test file");
for flag in flags {
let kebab = flag.trim_start_matches("--");
let snake = kebab.replace('-', "_");
assert!(
test_content.contains(kebab) || test_content.contains(&snake),
"teste deve referenciar flag {flag} (procura por {kebab} ou {snake})"
);
}
}
#[test]
fn new_subcommands_listed_in_top_help() {
let output = common::atomwrite().args(["--help"]).output().expect("run");
assert!(output.status.success());
let help = String::from_utf8_lossy(&output.stdout);
assert!(
help.contains("edit-loop"),
"edit-loop deve aparecer em --help"
);
assert!(
help.contains("prune-backups"),
"prune-backups deve aparecer em --help"
);
}