28 lines
552 B
Go
28 lines
552 B
Go
|
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)
|
||
|
}
|