From 3a5e4b62d0bef7ac6344deaa804eea44c8d4fbef Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 9 Nov 2026 23:56:10 +0800 Subject: [PATCH] usage: TestRowTokensAndZoneKept compares the zone by name and offset The test compared got.Time.Location() with its own *time.Location by pointer. rowZones keeps the first zone it sees for a name and offset, so under -count=3 the second run got the first run's location back and the test went red on unchanged code. It now checks the zone's name and offset (IST, +5:30), which is what rowZones promises. Run on mote: go test ./internal/usage -count=1 ok; -run TestRowTokensAndZoneKept -count=3 ok (red on the old test). Broken by hand: writing the row with an "XST" zone turns it red. --- internal/usage/row_shape_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/usage/row_shape_test.go b/internal/usage/row_shape_test.go index c057e3217..2074c3ba0 100644 --- a/internal/usage/row_shape_test.go +++ b/internal/usage/row_shape_test.go @@ -84,7 +84,10 @@ func TestRowTokensAndZoneKept(t *testing.T) { if got.Input != math.MaxInt32 || got.Output != math.MinInt32 || got.CacheRead != 7 { t.Fatalf("read back Input %d, Output %d, CacheRead %d; want %d, %d, 7", got.Input, got.Output, got.CacheRead, math.MaxInt32, math.MinInt32) } - if !got.Time.Equal(at) || got.Time.Location() != zone || got.Time.Format(time.RFC3339Nano) != at.Format(time.RFC3339Nano) { + // the zone by its name and offset, as rowZones knows it: a run + // before this one in the process (-count) made the zone kept + name, offset := got.Time.Zone() + if !got.Time.Equal(at) || name != "IST" || offset != 5*3600+1800 || got.Time.Format(time.RFC3339Nano) != at.Format(time.RFC3339Nano) { t.Fatalf("read back time %v in %v, want %v", got.Time, got.Time.Location(), at) } if z := c.row(1).Time; !z.IsZero() {