parse arg test
This commit is contained in:
parent
8255c4b18b
commit
aeb8e3d741
|
@ -69,6 +69,36 @@ func TestParseArgs(t *testing.T) {
|
|||
Flags: map[string]string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "just main",
|
||||
args: []string{"one", "two three", "four"},
|
||||
expAS: &command.ArgSet{
|
||||
Main: "one two three four",
|
||||
Flags: map[string]string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with flags",
|
||||
args: []string{"-flag1", "value1", "one", "two", "-flag2", "value2", "-flag3", "value3"},
|
||||
expAS: &command.ArgSet{
|
||||
Main: "one two",
|
||||
Flags: map[string]string{
|
||||
"flag1": "value1",
|
||||
"flag2": "value2",
|
||||
"flag3": "value3",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "flag without value",
|
||||
args: []string{"one", "two", "-flag1"},
|
||||
expErr: true,
|
||||
},
|
||||
{
|
||||
name: "split main",
|
||||
args: []string{"one", "-flag1", "value1", "two"},
|
||||
expErr: true,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
actAS, actErr := command.ParseArgs(tc.args)
|
||||
|
|
Loading…
Reference in New Issue