@@ -5817,13 +5817,15 @@ func TestDefaultCommandWithSubcommandFlags(t *testing.T) {
58175817
58185818func TestDefaultCommandWithShortFlag (t * testing.T ) {
58195819 // Covers the short-flag splitting path in parseFlags when DefaultCommand is set
5820+ actionRun := false
58205821 cmd := & Command {
58215822 DefaultCommand : "run" ,
58225823 Commands : []* Command {
58235824 {
58245825 Name : "run" ,
58255826 Usage : "run the app" ,
58265827 Action : func (ctx context.Context , cmd * Command ) error {
5828+ actionRun = true
58275829 if cmd .String ("foo" ) != "baz" {
58285830 return fmt .Errorf ("expected foo=baz, got %s" , cmd .String ("foo" ))
58295831 }
@@ -5841,10 +5843,12 @@ func TestDefaultCommandWithShortFlag(t *testing.T) {
58415843
58425844 err := cmd .Run (buildTestContext (t ), []string {"c" , "-f" , "baz" })
58435845 assert .NoError (t , err )
5846+ assert .True (t , actionRun , "expected run action to be executed" )
58445847}
58455848
58465849func TestDefaultCommandWithShortFlagHandling (t * testing.T ) {
58475850 // Covers the shortOptionHandling for-loop path when DefaultCommand is set
5851+ actionRun := false
58485852 cmd := & Command {
58495853 UseShortOptionHandling : true ,
58505854 DefaultCommand : "run" ,
@@ -5853,6 +5857,7 @@ func TestDefaultCommandWithShortFlagHandling(t *testing.T) {
58535857 Name : "run" ,
58545858 Usage : "run the app" ,
58555859 Action : func (ctx context.Context , cmd * Command ) error {
5860+ actionRun = true
58565861 if cmd .String ("foo" ) != "baz" {
58575862 return fmt .Errorf ("expected foo=baz, got %s" , cmd .String ("foo" ))
58585863 }
@@ -5869,4 +5874,5 @@ func TestDefaultCommandWithShortFlagHandling(t *testing.T) {
58695874 }
58705875 err := cmd .Run (buildTestContext (t ), []string {"c" , "-f" , "baz" })
58715876 assert .NoError (t , err )
5877+ assert .True (t , actionRun , "expected run action to be executed" )
58725878}
0 commit comments