test(cli): add integration tests for disabled client feature

Verify that the CLI correctly reports the unavailability of the client applet and provides instructions on how to enable it via features.
This commit is contained in:
Nils Andreas Svee committed 2026-07-03 00:57:37 +07:00
1 parent baa2a862f5
commit c5ca3d5a93
1 file changed
+31
+31
View File
@@ -44,6 +44,7 @@ fn canonical_without_applet_errors() {
assert!(text.contains("server")); assert!(text.contains("server"));
} }
#[cfg(feature = "client")]
#[test] #[test]
fn canonical_client_subcommand_dispatches_to_client() { fn canonical_client_subcommand_dispatches_to_client() {
let output = irtt_rs().args(["client", "--help"]).output().unwrap(); let output = irtt_rs().args(["client", "--help"]).output().unwrap();
@@ -55,7 +56,21 @@ fn canonical_client_subcommand_dispatches_to_client() {
assert!(text.contains("--columns <COLUMNS>")); assert!(text.contains("--columns <COLUMNS>"));
} }
#[cfg(not(feature = "client"))]
#[test]
fn canonical_client_subcommand_reports_unavailable_when_disabled() {
let output = irtt_rs().args(["client", "--help"]).output().unwrap();
let text = output_text(&output);
assert!(!output.status.success());
assert!(
text.contains("client applet is not available; rebuild with the client feature"),
"{text}"
);
}
#[cfg(unix)] #[cfg(unix)]
#[cfg(feature = "client")]
#[test] #[test]
fn client_applet_name_dispatches_to_client() { fn client_applet_name_dispatches_to_client() {
let output = irtt_rs_with_arg0("irtt-cli") let output = irtt_rs_with_arg0("irtt-cli")
@@ -70,6 +85,22 @@ fn client_applet_name_dispatches_to_client() {
assert!(text.contains("--columns <COLUMNS>")); assert!(text.contains("--columns <COLUMNS>"));
} }
#[cfg(all(unix, not(feature = "client")))]
#[test]
fn client_applet_name_reports_unavailable_when_disabled() {
let output = irtt_rs_with_arg0("irtt-cli")
.arg("--help")
.output()
.unwrap();
let text = output_text(&output);
assert!(!output.status.success());
assert!(
text.contains("client applet is not available; rebuild with the client feature"),
"{text}"
);
}
#[cfg(all(unix, feature = "tui"))] #[cfg(all(unix, feature = "tui"))]
#[test] #[test]
fn tui_applet_name_dispatches_to_tui_when_enabled() { fn tui_applet_name_dispatches_to_tui_when_enabled() {