Skip to content

Commit

Permalink
💚 test: fix unit tests error on run go test
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Feb 11, 2023
1 parent 0eef495 commit 8e7b9a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ func TestApp_Run_command_withArguments(t *testing.T) {
argStr = ""
cmdRet = ""

err := app.Exec("test", []string{"val0", "val1"})
err := app.Exec("test", []string{"val0", "val1", "val2"})
is.NoErr(err)
is.Eq("test", cmdRet)
is.Eq("val0,val1", argStr)
is.Eq("val2", argStr)

err = app.Exec("not-exists", []string{})
is.Err(err)
Expand Down
8 changes: 5 additions & 3 deletions cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestCommand_NewErrf(t *testing.T) {
c.AddArg("arg0", "desc message")
})
c.SetFunc(func(c *gcli.Command, args []string) error {
is.Eq([]string{"hi"}, args)
is.Eq("hi", c.Arg("arg0").String())
return c.NewErrf("error message")
})

Expand Down Expand Up @@ -358,7 +358,8 @@ func TestCommand_Run_parseOptions(t *testing.T) {
// dump.P(gcli.GOpts(), c0.Context)
is.NoErr(err)
is.Eq("test", c0.Ctx.Get("name"))
is.Eq([]string{"txt"}, c0.Ctx.Get("args"))
is.Eq("txt", c0.Arg("arg0").String())
is.Empty(c0.Ctx.Get("args"))

is.Eq(10, int0)
is.Eq("abc", str0)
Expand All @@ -376,7 +377,8 @@ func TestCommand_Run_parseOptions(t *testing.T) {
c.IntOpt(&co.maxSteps, "max-step", "", 0, "setting the max step value")
c.AddArg("arg0", "arg0 desc")
}).WithFunc(func(c *gcli.Command, args []string) error {
is.Eq("[txt]", fmt.Sprint(args))
is.Eq("txt", c.Arg("arg0").String())
is.Empty(args)
return nil
})

Expand Down

0 comments on commit 8e7b9a8

Please sign in to comment.