Repository navigation
Expand file tree
/
Copy pathcli_help_integration.rs
More file actions
179 lines (160 loc) · 5 KB
/
Copy pathcli_help_integration.rs
File metadata and controls
179 lines (160 loc) · 5 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//! Rendered help and command-shape checks for the `openshell` binary.
mod common;
use common::run_isolated;
#[test]
fn root_help_shows_top_level_commands() {
let output = run_isolated(&["--help"]);
assert_eq!(output.code, 0, "openshell --help:\n{}", output.combined);
for command in ["gateway", "status", "sandbox", "forward", "logs", "policy"] {
assert!(
output.combined.contains(command),
"expected '{command}' in openshell --help:\n{}",
output.combined
);
}
}
#[test]
fn gateway_help_shows_registration_commands_and_omits_lifecycle_commands() {
let output = run_isolated(&["gateway", "--help"]);
assert_eq!(output.code, 0, "gateway --help:\n{}", output.combined);
for command in ["add", "remove", "login", "logout", "select", "info", "list"] {
assert!(
output.combined.contains(command),
"expected '{command}' in gateway --help:\n{}",
output.combined
);
}
for removed in ["start", "stop", "destroy"] {
assert!(
!output.combined.contains(removed),
"unexpected removed command '{removed}' in gateway --help:\n{}",
output.combined
);
}
}
#[test]
fn sandbox_help_shows_transfer_and_lifecycle_commands() {
let output = run_isolated(&["sandbox", "--help"]);
assert_eq!(output.code, 0, "sandbox --help:\n{}", output.combined);
for command in [
"upload", "download", "create", "get", "list", "delete", "connect",
] {
assert!(
output.combined.contains(command),
"expected '{command}' in sandbox --help:\n{}",
output.combined
);
}
}
#[test]
fn sandbox_create_help_shows_creation_flags() {
let output = run_isolated(&["sandbox", "create", "--help"]);
assert_eq!(
output.code, 0,
"sandbox create --help:\n{}",
output.combined
);
for flag in [
"--gpu",
"--upload",
"--no-git-ignore",
"--editor",
"--auto-providers",
"--no-auto-providers",
] {
assert!(
output.combined.contains(flag),
"expected '{flag}' in sandbox create --help:\n{}",
output.combined
);
}
}
#[test]
fn sandbox_connect_help_shows_editor_flag() {
let output = run_isolated(&["sandbox", "connect", "--help"]);
assert_eq!(
output.code, 0,
"sandbox connect --help:\n{}",
output.combined
);
assert!(output.combined.contains("--editor"), "{}", output.combined);
}
#[test]
fn gateway_add_help_shows_endpoint_and_gateway_type_flags() {
let output = run_isolated(&["gateway", "add", "--help"]);
assert_eq!(output.code, 0, "gateway add --help:\n{}", output.combined);
for expected in ["--name", "--remote", "--local"] {
assert!(
output.combined.contains(expected),
"expected '{expected}' in gateway add --help:\n{}",
output.combined
);
}
assert!(
output.combined.contains("endpoint") || output.combined.contains("<ENDPOINT>"),
"expected endpoint argument in gateway add --help:\n{}",
output.combined
);
}
#[test]
fn gateway_login_help_describes_authentication() {
let output = run_isolated(&["gateway", "login", "--help"]);
assert_eq!(output.code, 0, "gateway login --help:\n{}", output.combined);
let help = output.combined.to_lowercase();
assert!(
["authenticat", "cloudflare", "login", "browser"]
.iter()
.any(|term| help.contains(term)),
"expected auth-related gateway login help:\n{}",
output.combined
);
}
#[test]
fn removed_gateway_lifecycle_subcommands_fail_to_parse() {
for command in ["start", "stop", "destroy"] {
let output = run_isolated(&["gateway", command, "--help"]);
assert_ne!(
output.code, 0,
"gateway {command} should fail after lifecycle command removal"
);
assert!(
output.combined.contains("unrecognized subcommand")
|| output.combined.contains("error:"),
"expected parser error for gateway {command}:\n{}",
output.combined
);
}
}
#[test]
fn gateway_add_rejects_conflicting_type_flags() {
let conflicting = run_isolated(&[
"gateway",
"add",
"https://example.com",
"--remote",
"user@host",
"--local",
]);
assert_ne!(
conflicting.code, 0,
"--remote and --local should conflict:\n{}",
conflicting.combined
);
}
#[test]
fn gateway_add_rejects_removed_ssh_key_flag() {
let removed = run_isolated(&[
"gateway",
"add",
"https://example.com",
"--ssh-key",
"/tmp/fake-key",
]);
assert_ne!(
removed.code, 0,
"removed --ssh-key flag should fail:\n{}",
removed.combined
);
}