| 1 | package memoria |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "time" |
| 6 | ) |
| 7 | |
| 8 | // Since rastrillo fb806a2 every stored time scans back in time.UTC, where |
| 9 | // before it came back in time.Local. The pages that printed a stored time |
| 10 | // with no zone (a document's Updated, the Notion connector's Verified, |
| 11 | // Started and Finished) therefore changed meaning on any host not in UTC: |
| 12 | // the same clock reading, now a different zone, and nothing on the page |
| 13 | // saying which. stamp says UTC out loud, as the sources page already did, |
| 14 | // and converts first, so a time in any zone prints the same instant. |
| 15 | func TestStampSaysUTC(t *testing.T) { |
| 16 | at := time.Date(2026, 10, 6, 21, 5, 0, 0, time.UTC) |
| 17 | lisbonSummer := time.FixedZone("WEST", 3600) |
| 18 | for _, in := range []time.Time{at, at.In(lisbonSummer)} { |
| 19 | if got, want := stamp(in), "6 Oct 2026, 21:05 UTC"; got != want { |
| 20 | t.Errorf("stamp(%v) = %q, want %q", in, got, want) |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | // Every unlabelled display goes through stamp: viewRun's Started and |
| 26 | // Finished are the ones a fixture can reach without a database. |
| 27 | func TestRunTimesSayUTC(t *testing.T) { |
| 28 | start := time.Date(2026, 10, 6, 21, 5, 0, 0, time.FixedZone("WEST", 3600)) |
| 29 | end := start.Add(time.Minute) |
| 30 | v := viewRun(&SyncRun{StartedAt: start, FinishedAt: &end, Total: -1}) |
| 31 | if v.Started != "6 Oct 2026, 20:05 UTC" || v.Finished != "6 Oct 2026, 20:06 UTC" { |
| 32 | t.Errorf("run times = %q, %q; want them in UTC and labelled", v.Started, v.Finished) |
| 33 | } |
| 34 | } |
| 35 | |