MCPcopy Create free account
hub / github.com/cli/cli / Test_telemetryCommandPath

Function Test_telemetryCommandPath

internal/ghcmd/cmd_test.go:725–748  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

723}
724
725func 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}

Callers

nothing calls this directly

Calls 3

telemetryCommandPathFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected