1 Commits
Author SHA1 Message Date
sneak 6da4315f57 Label the version report's date line "commit date" (closes #409)
check / check (push) Failing after 17m39s
The value is the commit's date, which the Makefile and the Dockerfile
stamp in, not the time of the build. The other labels gain one space
so every value still starts in one column.

Model: opus-5-5
2026-11-10 19:57:35 +00:00
3 changed files with 15 additions and 63 deletions

No files matched your search

+1 -1
View File
@@ -90,7 +90,7 @@ func setupGlobals(
// blank line. Used both from the fx hook (for subcommand invocations) and
// from the root cobra Run handler (for `vaultik` with no subcommand).
func writeStartupBanner(w *ui.Writer, startTime time.Time, shortCommit string) {
w.Bannerf("%s %s by %s (commit %s, commit date %s) starting up at %s.",
w.Bannerf("%s %s by %s (commit %s, built on %s) starting up at %s.",
globals.Appname, globals.Version, globals.Author,
shortCommit, globals.CommitDate,
startTime.Format(time.RFC3339))
-30
View File
@@ -13,7 +13,6 @@ import (
"github.com/adrg/xdg"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"sneak.berlin/go/vaultik/internal/globals"
)
// Command words and flags used to build argument vectors below. They are
@@ -113,35 +112,6 @@ func TestBannerStillPrintedWithoutSuppressingFlag(t *testing.T) {
}
}
// TestBannerLabelsCommitDate checks that the banner prints the commit
// and the commit date, each after its own label. Commit and CommitDate
// get different values, so printing the wrong one fails.
//
//nolint:paralleltest // sets globals.Commit and globals.CommitDate
func TestBannerLabelsCommitDate(t *testing.T) {
const (
commit = "abc1234"
commitDate = "2026-11-09"
)
previousCommit, previousCommitDate := globals.Commit, globals.CommitDate
t.Cleanup(func() {
globals.Commit = previousCommit
globals.CommitDate = previousCommitDate
})
globals.Commit = commit
globals.CommitDate = commitDate
var banner bytes.Buffer
emitStartupBanner(nil, &banner)
assert.Contains(t, banner.String(),
"(commit "+commit+", commit date "+commitDate+")")
}
// TestBannerSuppressedInArgs covers the suppression scan directly,
// including the flags that suppressed the banner before --json joined
// them, so that adding --json cannot regress them.
+14 -32
View File
@@ -2,7 +2,6 @@ package cli_test
import (
"bytes"
"runtime"
"strings"
"testing"
@@ -50,39 +49,22 @@ func TestVersionCommandReportsBuildVersion(t *testing.T) {
}
}
// TestVersionCommandReportLines checks the label, padding and value of
// every line of the report. Commit and CommitDate get different values,
// so a line that prints the wrong one fails.
// 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 // sets globals.Commit and globals.CommitDate
func TestVersionCommandReportLines(t *testing.T) {
const (
commit = "abc1234"
commitDate = "2026-11-09"
)
previousCommit, previousCommitDate := globals.Commit, globals.CommitDate
t.Cleanup(func() {
globals.Commit = previousCommit
globals.CommitDate = previousCommitDate
})
globals.Commit = commit
globals.CommitDate = commitDate
want := "vaultik " + globals.Version + "\n" +
" commit: " + commit + "\n" +
" commit date: " + commitDate + "\n" +
" go: " + runtime.Version() + "\n" +
" os/arch: " + runtime.GOOS + "/" + runtime.GOARCH + "\n" +
" author: " + globals.Author + "\n" +
" homepage: " + globals.Homepage + "\n" +
" license: " + globals.License + "\n"
//nolint:paralleltest // executes a command that reads the global rootFlags
func TestVersionCommandLabelsCommitDate(t *testing.T) {
out := runVersionCommand(t)
if !strings.HasPrefix(out, want) {
t.Errorf("report:\n%s\nwant it to start with:\n%s", out, want)
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)
}
}