diff options
| author | Alex Flint <[email protected]> | 2019-04-30 13:30:23 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2019-04-30 13:30:23 -0700 |
| commit | af12b7cfc22b056f6232bb25f5f4b7d35ca37e7e (patch) | |
| tree | e0cd566ec0bfc60807c7acc745937921e1a46992 /subcommand_test.go | |
| parent | 6a796e2c4131f734028186c023c32e08b5ef7758 (diff) | |
introduced path struct
Diffstat (limited to 'subcommand_test.go')
| -rw-r--r-- | subcommand_test.go | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/subcommand_test.go b/subcommand_test.go index d17c604..02c7b54 100644 --- a/subcommand_test.go +++ b/subcommand_test.go @@ -4,12 +4,13 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // This file contains tests for parse.go but I decided to put them here // since that file is getting large -func TestSubcommandNotAStruct(t *testing.T) { +func TestSubcommandNotAPointer(t *testing.T) { var args struct { A string `arg:"subcommand"` } @@ -17,6 +18,14 @@ func TestSubcommandNotAStruct(t *testing.T) { assert.Error(t, err) } +func TestSubcommandNotAPointerToStruct(t *testing.T) { + var args struct { + A struct{} `arg:"subcommand"` + } + _, err := NewParser(Config{}, &args) + assert.Error(t, err) +} + func TestPositionalAndSubcommandNotAllowed(t *testing.T) { var args struct { A string `arg:"positional"` @@ -25,3 +34,14 @@ func TestPositionalAndSubcommandNotAllowed(t *testing.T) { _, err := NewParser(Config{}, &args) assert.Error(t, err) } + +func TestMinimalSubcommand(t *testing.T) { + type listCmd struct { + } + var args struct { + List *listCmd `arg:"subcommand"` + } + err := parse("list", &args) + require.NoError(t, err) + assert.NotNil(t, args.List) +} |
