add a unittest for an internally messed up subcommand path
This commit is contained in:
parent
960d38c3ce
commit
e7a4f77ed0
|
@ -495,3 +495,14 @@ func TestValForNilStruct(t *testing.T) {
|
||||||
v := p.val(path{fields: []reflect.StructField{subField, subField}})
|
v := p.val(path{fields: []reflect.StructField{subField, subField}})
|
||||||
assert.False(t, v.IsValid())
|
assert.False(t, v.IsValid())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSubcommandInvalidInternal(t *testing.T) {
|
||||||
|
// this situation should never arise in practice but still good to test for it
|
||||||
|
var cmd struct{}
|
||||||
|
p, err := NewParser(Config{}, &cmd)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
p.subcommand = []string{"should", "never", "happen"}
|
||||||
|
sub := p.Subcommand()
|
||||||
|
assert.Nil(t, sub)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue