(t *testing.T)
| 723 | } |
| 724 | |
| 725 | func Test_telemetryCommandPath(t *testing.T) { |
| 726 | rootCmd := &cobra.Command{Use: "gh"} |
| 727 | authCmd := &cobra.Command{Use: "auth"} |
| 728 | authCmd.AddCommand(&cobra.Command{Use: "token", Run: func(*cobra.Command, []string) {}}) |
| 729 | rootCmd.AddCommand(authCmd) |
| 730 | prCmd := &cobra.Command{Use: "pr"} |
| 731 | prCmd.AddCommand(&cobra.Command{Use: "list", Run: func(*cobra.Command, []string) {}}) |
| 732 | rootCmd.AddCommand(prCmd) |
| 733 | |
| 734 | tests := []struct { |
| 735 | name string |
| 736 | args []string |
| 737 | want string |
| 738 | }{ |
| 739 | {name: "listed command", args: []string{"auth", "token", "--hostname", "github.com"}, want: "gh auth token"}, |
| 740 | {name: "unlisted command", args: []string{"pr", "list"}, want: "other"}, |
| 741 | {name: "unknown command", args: []string{"my-extension"}, want: "other"}, |
| 742 | } |
| 743 | for _, tt := range tests { |
| 744 | t.Run(tt.name, func(t *testing.T) { |
| 745 | assert.Equal(t, tt.want, telemetryCommandPath(rootCmd, tt.args)) |
| 746 | }) |
| 747 | } |
| 748 | } |
nothing calls this directly
no test coverage detected