MCPcopy
hub / github.com/urfave/cli / TestCommand_Walk

Function TestCommand_Walk

command_test.go:6388–6405  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6386}
6387
6388func TestCommand_Walk(t *testing.T) {
6389 subCmd := &Command{Name: "bar"}
6390 subSubCmd := &Command{Name: "baz"}
6391 subCmd.Commands = []*Command{subSubCmd}
6392
6393 cmd := &Command{
6394 Name: "foo",
6395 Commands: []*Command{subCmd},
6396 }
6397
6398 var visited []string
6399 err := cmd.Walk(func(c *Command) error {
6400 visited = append(visited, c.Name)
6401 return nil
6402 })
6403 require.NoError(t, err)
6404 assert.Equal(t, []string{"foo", "bar", "baz"}, visited)
6405}
6406
6407func TestCommand_Walk_ShortCircuit(t *testing.T) {
6408 subCmd := &Command{Name: "bar"}

Callers

nothing calls this directly

Calls 1

WalkMethod · 0.95

Tested by

no test coverage detected