MCPcopy Index your code
hub / github.com/coder/coder / HandlersOK

Function HandlersOK

cli/clitest/handlers.go:14–24  ·  view source on GitHub ↗

HandlersOK asserts that all commands have a handler. Without a handler, the command has no default behavior. Even for non-root commands (like 'groups' or 'users'), a handler is required. These handlers are likely just the 'help' handler, but this must be explicitly set.

(t *testing.T, cmd *serpent.Command)

Source from the content-addressed store, hash-verified

12// These handlers are likely just the 'help' handler, but this must be
13// explicitly set.
14func HandlersOK(t *testing.T, cmd *serpent.Command) {
15 cmd.Walk(func(cmd *serpent.Command) {
16 if cmd.Handler == nil {
17 // If you see this error, make the Handler a helper invoker.
18 // Handler: func(inv *serpent.Invocation) error {
19 // return inv.Command.HelpHandler(inv)
20 // },
21 t.Errorf("command %q has no handler, change to a helper invoker using: 'inv.Command.HelpHandler(inv)'", cmd.Name())
22 }
23 })
24}

Callers 2

TestHandlersOKFunction · 0.92
TestEnterpriseHandlersOKFunction · 0.92

Calls 2

NameMethod · 0.65
ErrorfMethod · 0.45

Tested by 2

TestHandlersOKFunction · 0.74
TestEnterpriseHandlersOKFunction · 0.74