From b8bd3dd9b5e8bd58f18d7e726d3fe1db814efe7f Mon Sep 17 00:00:00 2001 From: Ben Lovell Date: Thu, 30 Jul 2026 16:25:41 +0200 Subject: [PATCH] fix: help text tests no longer depend on terminal width --- crates/tower-cmd/src/catalogs.rs | 10 ++++++---- crates/tower-cmd/src/lib.rs | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/tower-cmd/src/catalogs.rs b/crates/tower-cmd/src/catalogs.rs index 1bc6ea19..7b42bff0 100644 --- a/crates/tower-cmd/src/catalogs.rs +++ b/crates/tower-cmd/src/catalogs.rs @@ -1854,8 +1854,10 @@ mod tests { #[test] fn catalog_help_marks_storage_beta_in_short_and_long_help() { - let short_help = catalogs_cmd().render_help().to_string(); - let long_help = catalogs_cmd().render_long_help().to_string(); + // term_width(0) turns off help wrapping, which otherwise follows the + // width of the terminal the tests run in. + let short_help = catalogs_cmd().term_width(0).render_help().to_string(); + let long_help = catalogs_cmd().term_width(0).render_long_help().to_string(); for help in [short_help, long_help] { assert!(help.contains("includes Storage [beta]")); @@ -1865,7 +1867,7 @@ mod tests { #[test] fn storage_specific_command_and_flag_are_marked_beta() { - let mut command = catalogs_cmd(); + let mut command = catalogs_cmd().mut_subcommand("credentials", |c| c.term_width(0)); let credentials_help = command .find_subcommand_mut("credentials") .expect("credentials command should exist") @@ -1874,7 +1876,7 @@ mod tests { assert!(credentials_help .contains("Vend short-lived catalog credentials for external tools [beta]")); - let mut command = catalogs_cmd(); + let mut command = catalogs_cmd().mut_subcommand("list", |c| c.term_width(0)); let list_help = command .find_subcommand_mut("list") .expect("list command should exist") diff --git a/crates/tower-cmd/src/lib.rs b/crates/tower-cmd/src/lib.rs index 02cd8803..0bb92756 100644 --- a/crates/tower-cmd/src/lib.rs +++ b/crates/tower-cmd/src/lib.rs @@ -351,7 +351,9 @@ mod tests { #[test] fn root_help_scopes_beta_label_to_storage() { - let help = root_cmd().render_help().to_string(); + // term_width(0) turns off help wrapping, which otherwise follows the + // width of the terminal the tests run in. + let help = root_cmd().term_width(0).render_help().to_string(); assert!(help.contains( "Interact with the catalogs in your Tower account (includes Storage [beta])"