1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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());
}
|