(t *testing.T)
| 2362 | } |
| 2363 | |
| 2364 | func TestTraverseWithBadParentFlags(t *testing.T) { |
| 2365 | rootCmd := &Command{Use: "root", TraverseChildren: true} |
| 2366 | |
| 2367 | childCmd := &Command{Use: "child"} |
| 2368 | childCmd.Flags().String("str", "", "") |
| 2369 | rootCmd.AddCommand(childCmd) |
| 2370 | |
| 2371 | expected := "unknown flag: --str" |
| 2372 | |
| 2373 | c, _, err := rootCmd.Traverse([]string{"--str", "ok", "child"}) |
| 2374 | if err == nil || !strings.Contains(err.Error(), expected) { |
| 2375 | t.Errorf("Expected error, %q, got %q", expected, err) |
| 2376 | } |
| 2377 | if c != nil { |
| 2378 | t.Errorf("Expected nil command") |
| 2379 | } |
| 2380 | } |
| 2381 | |
| 2382 | func TestTraverseWithBadChildFlag(t *testing.T) { |
| 2383 | rootCmd := &Command{Use: "root", TraverseChildren: true} |
nothing calls this directly
no test coverage detected