(t *testing.T)
| 2380 | } |
| 2381 | |
| 2382 | func TestTraverseWithBadChildFlag(t *testing.T) { |
| 2383 | rootCmd := &Command{Use: "root", TraverseChildren: true} |
| 2384 | rootCmd.Flags().String("str", "", "") |
| 2385 | |
| 2386 | childCmd := &Command{Use: "child"} |
| 2387 | rootCmd.AddCommand(childCmd) |
| 2388 | |
| 2389 | // Expect no error because the last commands args shouldn't be parsed in |
| 2390 | // Traverse. |
| 2391 | c, args, err := rootCmd.Traverse([]string{"child", "--str"}) |
| 2392 | if err != nil { |
| 2393 | t.Errorf("Unexpected error: %v", err) |
| 2394 | } |
| 2395 | if len(args) != 1 && args[0] != "--str" { |
| 2396 | t.Errorf("Wrong args: %v", args) |
| 2397 | } |
| 2398 | if c.Name() != childCmd.Name() { |
| 2399 | t.Errorf("Expected command %q, got: %q", childCmd.Name(), c.Name()) |
| 2400 | } |
| 2401 | } |
| 2402 | |
| 2403 | func TestTraverseWithTwoSubcommands(t *testing.T) { |
| 2404 | rootCmd := &Command{Use: "root", TraverseChildren: true} |
nothing calls this directly
no test coverage detected