cli args moved from Init() to Parse()
This commit is contained in:
+6
-6
@@ -26,8 +26,8 @@ func TestOneOptWithEqual(t *testing.T) {
|
||||
"--color=blue",
|
||||
}
|
||||
|
||||
cli.Init(args, "1.0.0", "TestOneOptWithEqual description")
|
||||
if err := cli.Parse(); err != nil {
|
||||
cli.Init("1.0.0", "TestOneOptWithEqual description")
|
||||
if err := cli.Parse(args); err != nil {
|
||||
t.Error(err)
|
||||
} else if color != "blue" {
|
||||
t.Errorf("Expected color blue, got %q", color)
|
||||
@@ -54,8 +54,8 @@ func testIntArrayOptOk(t *testing.T, n int, args []string, flags ...int16) {
|
||||
var cli CliParser
|
||||
t.Logf("Arg set n. %d", n)
|
||||
addBoxOption(&cli, &box)
|
||||
cli.Init(args, "1.0.0", "TestIntArrayOpt description", flags...)
|
||||
if err := cli.Parse(); err != nil {
|
||||
cli.Init("1.0.0", "TestIntArrayOpt description", flags...)
|
||||
if err := cli.Parse(args); err != nil {
|
||||
t.Error(err)
|
||||
} else if len(box) != 4 {
|
||||
t.Errorf(`Expected 4 items, got %d`, len(box))
|
||||
@@ -67,8 +67,8 @@ func testIntArrayOptKo(t *testing.T, n int, args []string, msg string, flags ...
|
||||
var cli CliParser
|
||||
t.Logf("Arg set n. %d", n)
|
||||
addBoxOption(&cli, &box)
|
||||
cli.Init(args, "1.0.0", "TestIntArrayOpt description", flags...)
|
||||
if err := cli.Parse(); err == nil {
|
||||
cli.Init("1.0.0", "TestIntArrayOpt description", flags...)
|
||||
if err := cli.Parse(args); err == nil {
|
||||
t.Errorf("Expected error, got nil")
|
||||
} else if err.Error() != msg {
|
||||
t.Errorf(`Invalid error: %q; expected: %q`, err.Error(), msg)
|
||||
|
||||
Reference in New Issue
Block a user