From 6a796e2c4131f734028186c023c32e08b5ef7758 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Tue, 30 Apr 2019 12:54:39 -0700 Subject: [PATCH] add first two subcommand tests --- subcommand_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 subcommand_test.go diff --git a/subcommand_test.go b/subcommand_test.go new file mode 100644 index 0000000..d17c604 --- /dev/null +++ b/subcommand_test.go @@ -0,0 +1,27 @@ +package arg + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// 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) { + var args struct { + A string `arg:"subcommand"` + } + _, err := NewParser(Config{}, &args) + assert.Error(t, err) +} + +func TestPositionalAndSubcommandNotAllowed(t *testing.T) { + var args struct { + A string `arg:"positional"` + B struct{} `arg:"subcommand"` + } + _, err := NewParser(Config{}, &args) + assert.Error(t, err) +}