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

Function TestFindAlias

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

Source from the content-addressed store, hash-verified

53}
54
55func TestFindAlias(t *testing.T) {
56 cmd := newCmd("root", "")
57 subcmd := newCmd("child1", "")
58 subcmd.Aliases = []string{"alias1", "alias2"}
59 cmd.AddCmd(subcmd)
60
61 res, err := cmd.FindCmd([]string{"alias1"})
62 if err != nil {
63 t.Fatal("finding alias should work")
64 }
65 assert.Equal(t, res.Name, "child1")
66
67 res, err = cmd.FindCmd([]string{"alias2"})
68 if err != nil {
69 t.Fatal("finding alias should work")
70 }
71 assert.Equal(t, res.Name, "child1")
72
73 res, err = cmd.FindCmd([]string{"alias3"})
74 if err == nil {
75 t.Fatal("should not find this child!")
76 }
77 assert.Nil(t, res)
78}
79
80func TestHelpText(t *testing.T) {
81 cmd := newCmd("root", "help for root command")

Callers

nothing calls this directly

Calls 3

newCmdFunction · 0.85
FindCmdMethod · 0.80
AddCmdMethod · 0.45

Tested by

no test coverage detected