diff options
| author | Alex Flint <[email protected]> | 2023-10-08 20:24:18 -0400 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2023-10-08 20:24:18 -0400 |
| commit | e7a4f77ed026b53d5c2c1e1fea3001f8d7700cf7 (patch) | |
| tree | 3098a14958c19a03d80dbb79185d9c1fb67362b4 | |
| parent | 960d38c3ce9120355d59dc8f7ae83593046cf519 (diff) | |
add a unittest for an internally messed up subcommand path
| -rw-r--r-- | subcommand_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/subcommand_test.go b/subcommand_test.go index b215d3d..00efae0 100644 --- a/subcommand_test.go +++ b/subcommand_test.go @@ -495,3 +495,14 @@ func TestValForNilStruct(t *testing.T) { v := p.val(path{fields: []reflect.StructField{subField, subField}}) 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) +} |
