Skip to content

Commit 4d43690

Browse files
committed
test: Add explicit CLI test for --timeout 0 behavior (issue #112)
Adds test_cli_timeout_zero_is_unlimited to verify the fix for GitHub issue #112: - --timeout 0 is parsed as Some(0) (unlimited) - --timeout N is parsed as Some(N) - No --timeout flag results in None (use config/default)
1 parent b22d792 commit 4d43690

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/timeout_test.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,30 @@ clusters:
6969
assert_eq!(config.defaults.timeout, Some(0));
7070
assert_eq!(config.get_timeout(Some("production")), Some(0));
7171
}
72+
73+
/// Test that --timeout 0 is correctly parsed as Some(0) for unlimited timeout
74+
/// This is the fix for GitHub issue #112
75+
#[test]
76+
fn test_cli_timeout_zero_is_unlimited() {
77+
use bssh::cli::Cli;
78+
use clap::Parser;
79+
80+
// Test --timeout 0 is parsed as Some(0), meaning unlimited
81+
let args = vec!["bssh", "-H", "user@host", "--timeout", "0", "echo", "test"];
82+
let cli = Cli::try_parse_from(args).expect("Should parse --timeout 0");
83+
assert_eq!(
84+
cli.timeout,
85+
Some(0),
86+
"--timeout 0 should be Some(0) for unlimited"
87+
);
88+
89+
// Test --timeout with non-zero value
90+
let args = vec!["bssh", "-H", "user@host", "--timeout", "60", "echo", "test"];
91+
let cli = Cli::try_parse_from(args).expect("Should parse --timeout 60");
92+
assert_eq!(cli.timeout, Some(60), "--timeout 60 should be Some(60)");
93+
94+
// Test no --timeout flag results in None (will use config or default)
95+
let args = vec!["bssh", "-H", "user@host", "echo", "test"];
96+
let cli = Cli::try_parse_from(args).expect("Should parse without --timeout");
97+
assert_eq!(cli.timeout, None, "No --timeout should be None");
98+
}

0 commit comments

Comments
 (0)