MCPcopy
hub / github.com/urfave/cli / TestCommand_Run_CustomFlagCanUseVersionAlias

Function TestCommand_Run_CustomFlagCanUseVersionAlias

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

Source from the content-addressed store, hash-verified

2713}
2714
2715func TestCommand_Run_CustomFlagCanUseVersionAlias(t *testing.T) {
2716 buf := new(bytes.Buffer)
2717 called := false
2718
2719 cmd := &Command{
2720 Name: "boom",
2721 Version: "0.1.0",
2722 Writer: buf,
2723 Flags: []Flag{
2724 &BoolFlag{Name: "verbose", Aliases: []string{"v"}},
2725 },
2726 Action: func(_ context.Context, cmd *Command) error {
2727 called = true
2728 assert.True(t, cmd.Bool("verbose"))
2729 return nil
2730 },
2731 }
2732
2733 err := cmd.Run(buildTestContext(t), []string{"boom", "-v"})
2734
2735 assert.NoError(t, err)
2736 assert.True(t, called)
2737 assert.Empty(t, buf.String())
2738}
2739
2740func TestCommand_Run_Categories(t *testing.T) {
2741 buf := new(bytes.Buffer)

Callers

nothing calls this directly

Calls 4

BoolMethod · 0.95
RunMethod · 0.95
buildTestContextFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected