MCPcopy Index your code
hub / github.com/docker/cli / TestGetCommandName

Function TestGetCommandName

cli/command/telemetry_utils_test.go:68–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestGetCommandName(t *testing.T) {
69 rootCmd, childCmd, grandchildCmd := setupCobraCommands()
70
71 t.Parallel()
72
73 for _, tc := range []struct {
74 testName string
75 cmd *cobra.Command
76 expected string
77 }{
78 {
79 testName: "rootCmd",
80 cmd: rootCmd,
81 expected: "",
82 },
83 {
84 testName: "childCmd",
85 cmd: childCmd,
86 expected: "child",
87 },
88 {
89 testName: "grandchildCmd",
90 cmd: grandchildCmd,
91 expected: "child grandchild",
92 },
93 } {
94 t.Run(tc.testName, func(t *testing.T) {
95 t.Parallel()
96 actual := getCommandName(tc.cmd)
97 assert.Equal(t, actual, tc.expected)
98 })
99 }
100}
101
102func TestStdioAttributes(t *testing.T) {
103 outBuffer := new(bytes.Buffer)

Callers

nothing calls this directly

Calls 2

setupCobraCommandsFunction · 0.85
getCommandNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…