orchard
mirrorEvery site I host, in one repo, along with the Cloudflare Tunnel and Caddy that front them. It's all Go, Vite, and SQLite, and it runs on a desktop at home with nothing listening on an inbound port.
blogbuncaddycloudflare-tunneldockergogolanghomelabhtml-templatemonorepoself-hostedseosqlitestatic-sitetypstuptime-monitoringviteweb-analytics
1package main
2
3import (
4 "testing"
5 "time"
6)
7
8func TestStaleFutures(t *testing.T) {
9 now := time.Date(2026, time.September, 5, 12, 0, 0, 0, time.UTC)
10
11 flagged := []string{
12 "Artemis II is scheduled for April 2026 as the first crewed lunar flyby.",
13 "The updated timeline targets the first crewed lunar flyby for April 2026.",
14 "The mission will launch in March 2026 from Kennedy Space Center.",
15 "A decision is expected in January 2026.",
16 }
17 for _, s := range flagged {
18 if got := staleFutures(s, now); len(got) == 0 {
19 t.Errorf("missed a past date written as upcoming: %q", s)
20 }
21 }
22
23 clean := []string{
24 // Genuinely ahead.
25 "Artemis IV is scheduled for early 2028.",
26 "The next launch is planned for December 2026.",
27 // This month is not past.
28 "A hearing is scheduled for September 2026.",
29 // Past tense about a past date is right.
30 "Artemis II launched in April 2026 and returned ten days later.",
31 "The report was published in March 2026.",
32 // No date at all.
33 "The programme is years behind schedule.",
34 }
35 for _, s := range clean {
36 if got := staleFutures(s, now); len(got) != 0 {
37 t.Errorf("false positive on %q: %v", s, got)
38 }
39 }
40
41 // One warning per month, not one per mention.
42 twice := "It is scheduled for April 2026. It remains planned for April 2026."
43 if got := staleFutures(twice, now); len(got) != 1 {
44 t.Errorf("want one warning for a repeated month, got %d: %v", len(got), got)
45 }
46}
47
48func TestStaleNow(t *testing.T) {
49 now := time.Date(2026, time.September, 5, 12, 0, 0, 0, time.UTC)
50
51 flagged := []string{
52 "Artemis II is currently active: the mission reached Trans-Lunar Injection, with the crew cleared for launch on April 2, 2026.",
53 "The mission is currently underway following its April 2026 launch.",
54 "The trial is ongoing as of March 2026.",
55 }
56 for _, s := range flagged {
57 if got := staleNow(s, now); len(got) == 0 {
58 t.Errorf("missed stale present tense: %q", s)
59 }
60 }
61
62 clean := []string{
63 // Dated to this month, so "currently" is fair.
64 "The mission is currently underway, having launched on September 2, 2026.",
65 // Present tense with no date attached is not evidence of staleness.
66 "The programme is currently years behind schedule.",
67 // Past tense about a past date carries no present-tense marker.
68 "Artemis II launched on April 2, 2026 and returned ten days later.",
69 }
70 for _, s := range clean {
71 if got := staleNow(s, now); len(got) != 0 {
72 t.Errorf("false positive on %q: %v", s, got)
73 }
74 }
75}