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

Function TestVisitAll

cmd/docker/docker_test.go:191–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

189}
190
191func TestVisitAll(t *testing.T) {
192 root := &cobra.Command{Use: "root"}
193 sub1 := &cobra.Command{Use: "sub1"}
194 sub1sub1 := &cobra.Command{Use: "sub1sub1"}
195 sub1sub2 := &cobra.Command{Use: "sub1sub2"}
196 sub2 := &cobra.Command{Use: "sub2"}
197
198 root.AddCommand(sub1, sub2)
199 sub1.AddCommand(sub1sub1, sub1sub2)
200
201 var visited []string
202 visitAll(root, func(ccmd *cobra.Command) {
203 visited = append(visited, ccmd.Name())
204 })
205 expected := []string{"sub1sub1", "sub1sub2", "sub1", "sub2", "root"}
206 assert.DeepEqual(t, expected, visited)
207}

Callers

nothing calls this directly

Calls 2

visitAllFunction · 0.70
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…