From d21ee513fd65842fbb4ba7c1314fed0efb14afa7 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 15 Nov 2022 10:12:05 -0600 Subject: [PATCH] test(parser): Verify subcommand required message --- tests/builder/app_settings.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/builder/app_settings.rs b/tests/builder/app_settings.rs index c9c8cf5a525..8c1f4a34634 100644 --- a/tests/builder/app_settings.rs +++ b/tests/builder/app_settings.rs @@ -58,6 +58,23 @@ fn sub_command_required() { assert_eq!(err.kind(), ErrorKind::MissingSubcommand); } +#[test] +#[cfg(feature = "error-context")] +fn sub_command_required_error() { + static ERROR: &str = "\ +error: 'sc_required' requires a subcommand but one was not provided + +Usage: sc_required + +For more information try '--help' +"; + + let cmd = Command::new("sc_required") + .subcommand_required(true) + .subcommand(Command::new("sub1")); + utils::assert_output(cmd, "sc_required", ERROR, true); +} + #[test] fn arg_required_else_help() { let result = Command::new("arg_required")