(t *testing.T)
| 2688 | } |
| 2689 | |
| 2690 | func 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 | |
| 2715 | func TestCommand_Run_CustomFlagCanUseVersionAlias(t *testing.T) { |
| 2716 | buf := new(bytes.Buffer) |
nothing calls this directly
no test coverage detected