|
|
|
@ -12,41 +12,34 @@ func TestQuerier_Program(t *testing.T) {
|
|
|
|
|
name string
|
|
|
|
|
args []string
|
|
|
|
|
cfg *argh.ParserConfig
|
|
|
|
|
exp argh.Command
|
|
|
|
|
exp string
|
|
|
|
|
expOK bool
|
|
|
|
|
}{
|
|
|
|
|
{
|
|
|
|
|
name: "typical",
|
|
|
|
|
args: []string{"pizzas", "ahoy", "--treatsa", "fun"},
|
|
|
|
|
exp: argh.Command{Name: "pizzas"},
|
|
|
|
|
exp: "pizzas",
|
|
|
|
|
expOK: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "minimal",
|
|
|
|
|
args: []string{"pizzas"},
|
|
|
|
|
exp: argh.Command{Name: "pizzas"},
|
|
|
|
|
exp: "pizzas",
|
|
|
|
|
expOK: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "invalid",
|
|
|
|
|
args: []string{},
|
|
|
|
|
exp: argh.Command{},
|
|
|
|
|
expOK: false,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "invalid flag only",
|
|
|
|
|
args: []string{"--oh-no"},
|
|
|
|
|
exp: argh.Command{},
|
|
|
|
|
expOK: false,
|
|
|
|
|
},
|
|
|
|
|
} {
|
|
|
|
|
t.Run(tc.name, func(ct *testing.T) {
|
|
|
|
|
pt, err := argh.ParseArgs(tc.args, tc.cfg)
|
|
|
|
|
pt, err := argh.ParseArgs2(tc.args, tc.cfg)
|
|
|
|
|
require.Nil(ct, err)
|
|
|
|
|
|
|
|
|
|
prog, ok := argh.NewQuerier(pt.Nodes).Program()
|
|
|
|
|
require.Equal(ct, tc.exp, prog)
|
|
|
|
|
require.Equal(ct, tc.expOK, ok)
|
|
|
|
|
require.Equal(ct, tc.exp, prog.Name)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|