aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/cli.rs
diff options
context:
space:
mode:
authorMarcus Michaels <marcusmmichaels@gmail.com>2026-02-18 12:29:08 +0000
committerGitHub <noreply@github.com>2026-02-18 13:29:08 +0100
commit928708097435245d28c34d424da555b6850908d5 (patch)
tree3b4926d20d4063d940bd90d9bc3f3fae5cdd0991 /src/tests/cli.rs
parentfix grid crashes on invalid state (#4718) (diff)
downloadsl0ppij-928708097435245d28c34d424da555b6850908d5.tar.gz
sl0ppij-928708097435245d28c34d424da555b6850908d5.tar.xz
sl0ppij-928708097435245d28c34d424da555b6850908d5.zip
fix: add --timeout flag to zellij web --status (#4706)
* feat: add --timeout flag to zellij web --status The HTTP client for checking web server status didn't have a timeout configured. This could cause the CLI to hang indefinitely if the server was unreachable, so I've added a 30-second default timeout and lets users override it with `--timeout <seconds>` when running `zellij web --status`. For example: ``` zellij web --status --timeout 60 ``` * Update web timeout to work with --status (and add some tests to make sure everything works as expected)
Diffstat (limited to 'src/tests/cli.rs')
-rw-r--r--src/tests/cli.rs69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/tests/cli.rs b/src/tests/cli.rs
new file mode 100644
index 00000000..95864d56
--- /dev/null
+++ b/src/tests/cli.rs
@@ -0,0 +1,69 @@
+use clap::Parser;
+use zellij_utils::cli::{CliArgs, Command};
+
+#[test]
+fn web_cli_status_alone_works() {
+ let args = CliArgs::try_parse_from(["zellij", "web", "--status"]);
+ assert!(args.is_ok());
+ if let Ok(CliArgs {
+ command: Some(Command::Web(web)),
+ ..
+ }) = args
+ {
+ assert!(web.status);
+ assert!(web.timeout.is_none());
+ } else {
+ panic!("Expected Web command");
+ }
+}
+
+#[test]
+fn web_cli_status_with_timeout_works() {
+ let args = CliArgs::try_parse_from(["zellij", "web", "--status", "--timeout", "5"]);
+ assert!(args.is_ok());
+ if let Ok(CliArgs {
+ command: Some(Command::Web(web)),
+ ..
+ }) = args
+ {
+ assert!(web.status);
+ assert_eq!(web.timeout, Some(5));
+ } else {
+ panic!("Expected Web command");
+ }
+}
+
+#[test]
+fn web_cli_timeout_with_status_works() {
+ // Test with --timeout before --status (order shouldn't matter)
+ let args = CliArgs::try_parse_from(["zellij", "web", "--timeout", "10", "--status"]);
+ assert!(args.is_ok());
+ if let Ok(CliArgs {
+ command: Some(Command::Web(web)),
+ ..
+ }) = args
+ {
+ assert!(web.status);
+ assert_eq!(web.timeout, Some(10));
+ } else {
+ panic!("Expected Web command");
+ }
+}
+
+#[test]
+fn web_cli_timeout_without_status_fails() {
+ let args = CliArgs::try_parse_from(["zellij", "web", "--timeout", "5"]);
+ assert!(args.is_err());
+}
+
+#[test]
+fn web_cli_status_with_start_fails() {
+ let args = CliArgs::try_parse_from(["zellij", "web", "--status", "--start"]);
+ assert!(args.is_err());
+}
+
+#[test]
+fn web_cli_status_with_stop_fails() {
+ let args = CliArgs::try_parse_from(["zellij", "web", "--status", "--stop"]);
+ assert!(args.is_err());
+}