MCPcopy
hub / github.com/spf13/cobra / TestRemoveCommand

Function TestRemoveCommand

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

Source from the content-addressed store, hash-verified

1583}
1584
1585func TestRemoveCommand(t *testing.T) {
1586 rootCmd := &Command{Use: "root", Args: NoArgs, Run: emptyRun}
1587 childCmd := &Command{Use: "child", Run: emptyRun}
1588 rootCmd.AddCommand(childCmd)
1589 rootCmd.RemoveCommand(childCmd)
1590
1591 _, err := executeCommand(rootCmd, "child")
1592 if err == nil {
1593 t.Error("Expected error on calling removed command. Got nil.")
1594 }
1595}
1596
1597func TestReplaceCommandWithRemove(t *testing.T) {
1598 childUsed := 0

Callers

nothing calls this directly

Calls 4

AddCommandMethod · 0.95
RemoveCommandMethod · 0.95
executeCommandFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected