From a2c7c94f5d3c53f91f78a8fb36040ee2f682f64a Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Sun, 3 May 2026 06:54:05 -0500 Subject: [PATCH] test(pr): pin is_command_available contract (#451 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a tiny test that exercises both branches of the helper used by `deepseek pr ` 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. --- crates/tui/src/main.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/tui/src/main.rs b/crates/tui/src/main.rs index ec225aed..a37b0c02 100644 --- a/crates/tui/src/main.rs +++ b/crates/tui/src/main.rs @@ -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" + ); + } }