(t *testing.T)
| 2401 | } |
| 2402 | |
| 2403 | func TestTraverseWithTwoSubcommands(t *testing.T) { |
| 2404 | rootCmd := &Command{Use: "root", TraverseChildren: true} |
| 2405 | |
| 2406 | subCmd := &Command{Use: "sub", TraverseChildren: true} |
| 2407 | rootCmd.AddCommand(subCmd) |
| 2408 | |
| 2409 | subsubCmd := &Command{ |
| 2410 | Use: "subsub", |
| 2411 | } |
| 2412 | subCmd.AddCommand(subsubCmd) |
| 2413 | |
| 2414 | c, _, err := rootCmd.Traverse([]string{"sub", "subsub"}) |
| 2415 | if err != nil { |
| 2416 | t.Fatalf("Unexpected error: %v", err) |
| 2417 | } |
| 2418 | if c.Name() != subsubCmd.Name() { |
| 2419 | t.Fatalf("Expected command: %q, got %q", subsubCmd.Name(), c.Name()) |
| 2420 | } |
| 2421 | } |
| 2422 | |
| 2423 | // TestUpdateName checks if c.Name() updates on changed c.Use. |
| 2424 | // Related to https://github.com/spf13/cobra/pull/422#discussion_r143918343. |
nothing calls this directly
no test coverage detected