Skip to content

Commit e7a4f77

Browse files
committed
add a unittest for an internally messed up subcommand path
1 parent 960d38c commit e7a4f77

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

subcommand_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -495,3 +495,14 @@ func TestValForNilStruct(t *testing.T) {
495495
v := p.val(path{fields: []reflect.StructField{subField, subField}})
496496
assert.False(t, v.IsValid())
497497
}
498+
499+
func TestSubcommandInvalidInternal(t *testing.T) {
500+
// this situation should never arise in practice but still good to test for it
501+
var cmd struct{}
502+
p, err := NewParser(Config{}, &cmd)
503+
require.NoError(t, err)
504+
505+
p.subcommand = []string{"should", "never", "happen"}
506+
sub := p.Subcommand()
507+
assert.Nil(t, sub)
508+
}

0 commit comments

Comments
 (0)