(t *testing.T)
| 615 | } |
| 616 | |
| 617 | func TestVersion(t *testing.T) { |
| 618 | t.Parallel() |
| 619 | |
| 620 | ctx := context.Background() |
| 621 | |
| 622 | type testBundle struct { |
| 623 | buf *bytes.Buffer |
| 624 | } |
| 625 | |
| 626 | setup := func(t *testing.T) (*version, *testBundle) { |
| 627 | t.Helper() |
| 628 | |
| 629 | cmd, buf := withCommandBase(t, &version{}) |
| 630 | |
| 631 | return cmd, &testBundle{ |
| 632 | buf: buf, |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | t.Run("PrintsVersion", func(t *testing.T) { |
| 637 | t.Parallel() |
| 638 | |
| 639 | cmd, bundle := setup(t) |
| 640 | |
| 641 | _, err := runCommand(ctx, t, cmd, &versionOpts{Name: "River"}) |
| 642 | require.NoError(t, err) |
| 643 | |
| 644 | buildInfo, _ := debug.ReadBuildInfo() |
| 645 | |
| 646 | // `devel` on 1.25, `unknown` on versions previous to that |
| 647 | require.Regexp(t, strings.TrimSpace(fmt.Sprintf(` |
| 648 | River version \((devel|unknown)\) |
| 649 | Built with %s |
| 650 | `, buildInfo.GoVersion)), strings.TrimSpace(bundle.buf.String())) |
| 651 | }) |
| 652 | } |
| 653 | |
| 654 | // runCommand runs a CLI command while doing some additional niceties like |
| 655 | // validating options. |
nothing calls this directly
no test coverage detected
searching dependent graphs…