From 45f2b3d8e71e11822cf591f1c370f8587726c425 Mon Sep 17 00:00:00 2001 From: Lynn Cyrin Date: Thu, 1 Aug 2019 21:45:11 -0700 Subject: [PATCH] more test cases --- app_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app_test.go b/app_test.go index 1e42f12..465d3ce 100644 --- a/app_test.go +++ b/app_test.go @@ -949,6 +949,27 @@ func TestRequiredFlagAppRunBehavior(t *testing.T) { appFlags: []Flag{StringFlag{Name: "requiredFlag", Required: true}, StringFlag{Name: "optional"}}, expectedAnError: true, }, + { + testCase: "error_case_optional_input_with_required_flag_command", + appRunInput: []string{"myCLI", "myCommand", "--optional", "cats"}, + appCommands: []Command{Command{ + Name: "myCommand", + Flags: []Flag{StringFlag{Name: "requiredFlag", Required: true}, StringFlag{Name: "optional"}}, + }}, + expectedAnError: true, + }, + { + testCase: "error_case_optional_input_with_required_flag_subcommand", + appRunInput: []string{"myCLI", "myCommand", "mySubCommand", "--optional", "cats"}, + appCommands: []Command{Command{ + Name: "myCommand", + Subcommands: []Command{Command{ + Name: "mySubCommand", + Flags: []Flag{StringFlag{Name: "requiredFlag", Required: true}, StringFlag{Name: "optional"}}, + }}, + }}, + expectedAnError: true, + }, // valid input cases { testCase: "valid_case_required_flag_input",