diff --git a/internal/cli/version.go b/internal/cli/version.go index 0307060..400d6eb 100644 --- a/internal/cli/version.go +++ b/internal/cli/version.go @@ -37,13 +37,13 @@ func writeVersion(out *ui.Writer) { w := out.Out() _, _ = fmt.Fprintf(w, "vaultik %s\n", globals.Version) - _, _ = fmt.Fprintf(w, " commit: %s\n", globals.Commit) - _, _ = fmt.Fprintf(w, " build date: %s\n", globals.CommitDate) - _, _ = fmt.Fprintf(w, " go: %s\n", runtime.Version()) - _, _ = fmt.Fprintf(w, " os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) - _, _ = fmt.Fprintf(w, " author: %s\n", globals.Author) - _, _ = fmt.Fprintf(w, " homepage: %s\n", globals.Homepage) - _, _ = fmt.Fprintf(w, " license: %s\n", globals.License) + _, _ = fmt.Fprintf(w, " commit: %s\n", globals.Commit) + _, _ = fmt.Fprintf(w, " commit date: %s\n", globals.CommitDate) + _, _ = fmt.Fprintf(w, " go: %s\n", runtime.Version()) + _, _ = fmt.Fprintf(w, " os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + _, _ = fmt.Fprintf(w, " author: %s\n", globals.Author) + _, _ = fmt.Fprintf(w, " homepage: %s\n", globals.Homepage) + _, _ = fmt.Fprintf(w, " license: %s\n", globals.License) if globals.IsDevVersion(globals.Version) { _, _ = fmt.Fprintln(w) diff --git a/internal/cli/version_test.go b/internal/cli/version_test.go index 7068f9d..607b008 100644 --- a/internal/cli/version_test.go +++ b/internal/cli/version_test.go @@ -49,6 +49,25 @@ func TestVersionCommandReportsBuildVersion(t *testing.T) { } } +// TestVersionCommandLabelsCommitDate checks that the date line is +// labelled as the commit's date, which is what the build stamps into +// it, and that its value starts in the same column as the commit's. +// +//nolint:paralleltest // executes a command that reads the global rootFlags +func TestVersionCommandLabelsCommitDate(t *testing.T) { + out := runVersionCommand(t) + + wantLine := " commit date: " + globals.CommitDate + if !strings.Contains(out, wantLine+"\n") { + t.Errorf("output has no line %q:\n%s", wantLine, out) + } + + wantCommit := " commit: " + globals.Commit + if !strings.Contains(out, wantCommit+"\n") { + t.Errorf("output has no line %q:\n%s", wantCommit, out) + } +} + // TestVersionCommandFlagsDevelopmentBuild is the regression test for // the thing this command exists to prevent: a build that is not a // release must say so. The notice used to be gated on the version