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

Function TestCommand_Run_Version

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

Source from the content-addressed store, hash-verified

2688}
2689
2690func TestCommand_Run_Version(t *testing.T) {
2691 versionArguments := [][]string{{"boom", "--version"}, {"boom", "-v"}}
2692
2693 for _, args := range versionArguments {
2694 t.Run(fmt.Sprintf("checking with arguments %v", args), func(t *testing.T) {
2695 buf := new(bytes.Buffer)
2696
2697 cmd := &Command{
2698 Name: "boom",
2699 Usage: "make an explosive entrance",
2700 Version: "0.1.0",
2701 Writer: buf,
2702 Action: func(context.Context, *Command) error {
2703 buf.WriteString("boom I say!")
2704 return nil
2705 },
2706 }
2707
2708 err := cmd.Run(buildTestContext(t), args)
2709 assert.NoError(t, err)
2710 assert.Contains(t, buf.String(), "0.1.0", "want version to contain 0.1.0")
2711 })
2712 }
2713}
2714
2715func TestCommand_Run_CustomFlagCanUseVersionAlias(t *testing.T) {
2716 buf := new(bytes.Buffer)

Callers

nothing calls this directly

Calls 3

RunMethod · 0.95
buildTestContextFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected