From d862d5867253b7db5b41b6a4bc25946e1d290a38 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Thu, 22 Jan 2026 17:24:55 +0800 Subject: [PATCH] test: stabilize formatUnusedTime by using UTC baseline --- cmd/analyze/format_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/analyze/format_test.go b/cmd/analyze/format_test.go index de7022f..7cfdf57 100644 --- a/cmd/analyze/format_test.go +++ b/cmd/analyze/format_test.go @@ -310,6 +310,7 @@ func TestCalculateNameWidth(t *testing.T) { } func TestFormatUnusedTime(t *testing.T) { + now := time.Now().UTC() tests := []struct { name string daysAgo int @@ -334,8 +335,8 @@ func TestFormatUnusedTime(t *testing.T) { t.Run(tt.name, func(t *testing.T) { var lastAccess time.Time if tt.daysAgo >= 0 { - // Create a time that is tt.daysAgo days in the past - lastAccess = time.Now().AddDate(0, 0, -tt.daysAgo) + // Use a fixed UTC baseline to avoid DST-related flakiness. + lastAccess = now.Add(-time.Duration(tt.daysAgo) * 24 * time.Hour) } // If daysAgo < 0, lastAccess remains zero value