MCPcopy Index your code
hub / github.com/abiosoft/ishell / TestFindCmd

Function TestFindCmd

command_test.go:32–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestFindCmd(t *testing.T) {
33 cmd := newCmd("root", "")
34 cmd.AddCmd(newCmd("child1", ""))
35 cmd.AddCmd(newCmd("child2", ""))
36 res, err := cmd.FindCmd([]string{"child1"})
37 if err != nil {
38 t.Fatal("finding should work")
39 }
40 assert.Equal(t, res.Name, "child1")
41
42 res, err = cmd.FindCmd([]string{"child2"})
43 if err != nil {
44 t.Fatal("finding should work")
45 }
46 assert.Equal(t, res.Name, "child2")
47
48 res, err = cmd.FindCmd([]string{"child3"})
49 if err == nil {
50 t.Fatal("should not find this child!")
51 }
52 assert.Nil(t, res)
53}
54
55func TestFindAlias(t *testing.T) {
56 cmd := newCmd("root", "")

Callers

nothing calls this directly

Calls 3

newCmdFunction · 0.85
FindCmdMethod · 0.80
AddCmdMethod · 0.45

Tested by

no test coverage detected