test(pr): pin is_command_available contract (#451 follow-up)
Adds a tiny test that exercises both branches of the helper used by `deepseek pr <N>` to detect `gh`'s presence: * Positive case — `sh` (POSIX baseline) is reported present. Gated on `cfg(unix)` because Windows runners aren't guaranteed to have `sh.exe` outside git-bash. * Negative case — a deliberately-implausible `this-command-cannot-exist-…ENOENT-marker` returns `false` rather than panicking from the `Command::new` exec failure. Pure additive coverage; no production change.
This commit is contained in:
@@ -4429,4 +4429,21 @@ mod pr_prompt_tests {
|
||||
// if the cut logic regresses).
|
||||
assert!(prompt.is_ascii() || prompt.contains('🚀'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_command_available_detects_present_and_absent_binaries() {
|
||||
// `sh` is part of the POSIX baseline on every Unix runner and
|
||||
// ships with `git-bash` on Windows CI. It should be present.
|
||||
// (Skip on Windows CI without git-bash because the runner
|
||||
// could legitimately lack `sh.exe`.)
|
||||
#[cfg(unix)]
|
||||
assert!(is_command_available("sh"), "POSIX `sh` should be on PATH");
|
||||
|
||||
// A deliberately-implausible name to confirm the negative
|
||||
// branch — `--version` on this would exec(3) → ENOENT.
|
||||
assert!(
|
||||
!is_command_available("this-command-cannot-exist-deepseek-tui-test-ENOENT-marker"),
|
||||
"missing command should return false, not panic"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user