From 5b649de04338e2ce398b9b1de3dc5f16144bdcd4 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Thu, 2 May 2019 09:16:33 -0700 Subject: [PATCH] test no such subcommand --- subcommand_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/subcommand_test.go b/subcommand_test.go index 25689a4..783ff9c 100644 --- a/subcommand_test.go +++ b/subcommand_test.go @@ -28,8 +28,8 @@ func TestSubcommandNotAPointerToStruct(t *testing.T) { func TestPositionalAndSubcommandNotAllowed(t *testing.T) { var args struct { - A string `arg:"positional"` - B struct{} `arg:"subcommand"` + A string `arg:"positional"` + B *struct{} `arg:"subcommand"` } _, err := NewParser(Config{}, &args) assert.Error(t, err) @@ -46,6 +46,16 @@ func TestMinimalSubcommand(t *testing.T) { assert.NotNil(t, args.List) } +func TestNoSuchSubcommand(t *testing.T) { + type listCmd struct { + } + var args struct { + List *listCmd `arg:"subcommand"` + } + err := parse("invalid", &args) + assert.Error(t, err) +} + func TestNamedSubcommand(t *testing.T) { type listCmd struct { }