Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cli/commands/upgrade_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ func PrintVersionComparison(current, latest release.VersionInfo) {
fmt.Printf("Current commit: %s\n", sc)
}
if !current.BuildDate.IsZero() {
fmt.Printf("Current build: %s\n", current.BuildDate.Format("2006-01-02 15:04:05 UTC"))
fmt.Printf("Current build: %s\n", current.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC"))
}

fmt.Printf("\nLatest version: %s\n", latest.Version)
if sc := latest.ShortCommit(); sc != "" {
fmt.Printf("Latest commit: %s\n", sc)
}
if !latest.BuildDate.IsZero() {
fmt.Printf("Latest build: %s\n", latest.BuildDate.Format("2006-01-02 15:04:05 UTC"))
fmt.Printf("Latest build: %s\n", latest.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC"))
}
}

Expand All @@ -164,8 +164,8 @@ func CheckIfUpgradeNeeded(ctx context.Context, targetVersion string, force bool,
} else {
fmt.Printf("Current version %s is already up to date (target: %s)\n", current.Version, latest.Version)
if !current.BuildDate.IsZero() && !latest.BuildDate.IsZero() {
fmt.Printf("Current build: %s\n", current.BuildDate.Format("2006-01-02 15:04:05 UTC"))
fmt.Printf("Target build: %s\n", latest.BuildDate.Format("2006-01-02 15:04:05 UTC"))
fmt.Printf("Current build: %s\n", current.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC"))
fmt.Printf("Target build: %s\n", latest.BuildDate.UTC().Format("2006-01-02 15:04:05 UTC"))
}
}
return false, nil
Expand Down
23 changes: 23 additions & 0 deletions cli/commands/upgrade_helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package commands

import (
"io"
"os"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"miren.dev/runtime/pkg/release"
)

func TestResolveVersionChannel(t *testing.T) {
Expand Down Expand Up @@ -60,3 +65,21 @@ func TestResolveVersionChannel(t *testing.T) {
})
}
}

func TestPrintVersionComparisonBuildDatesUTC(t *testing.T) {
stdout := os.Stdout
r, w, err := os.Pipe()
require.NoError(t, err)
os.Stdout = w
defer func() { os.Stdout = stdout }()
defer r.Close()

PrintVersionComparison(
release.VersionInfo{Version: "v1", BuildDate: time.Date(2026, 9, 14, 12, 48, 18, 0, time.FixedZone("CDT", -5*60*60))},
release.VersionInfo{Version: "v2", BuildDate: time.Date(2026, 9, 15, 4, 10, 17, 0, time.FixedZone("JST", 9*60*60))},
)
require.NoError(t, w.Close())
output, err := io.ReadAll(r)
require.NoError(t, err)
assert.Equal(t, "Current version: v1\nCurrent build: 2026-09-14 17:48:18 UTC\n\nLatest version: v2\nLatest build: 2026-09-14 19:10:17 UTC\n", string(output))
}
2 changes: 1 addition & 1 deletion cli/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func printBuildLines(ctx *Context, ver, commit string, built time.Time) {
ctx.Printf(" Commit: %s\n", commit)
}
if !built.IsZero() {
ctx.Printf(" Built: %s\n", built.Format("2006-01-02 15:04:05 UTC"))
ctx.Printf(" Built: %s\n", built.UTC().Format("2006-01-02 15:04:05 UTC"))
}
}

Expand Down
39 changes: 39 additions & 0 deletions cli/commands/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package commands

import (
"bytes"
"testing"
"time"
)

func TestPrintBuildLinesUTC(t *testing.T) {
tests := []struct {
name string
built time.Time
want string
}{
{
name: "server build in local timezone",
built: time.Date(2026, 9, 14, 12, 48, 18, 0, time.FixedZone("CDT", -5*60*60)),
want: " Version: v1\n Built: 2026-09-14 17:48:18 UTC\n",
},
{
name: "CLI build already in UTC",
built: time.Date(2026, 9, 14, 18, 10, 17, 0, time.UTC),
want: " Version: v1\n Built: 2026-09-14 18:10:17 UTC\n",
},
{
name: "unknown build date",
want: " Version: v1\n",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
var out bytes.Buffer
printBuildLines(&Context{Stdout: &out}, "v1", "", tt.built)
if got := out.String(); got != tt.want {
t.Fatalf("printBuildLines output = %q, want %q", got, tt.want)
}
})
}
}
Loading