repos
/ orchard main

orchard

mirror

Every 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

1.5 KB · 45 lines · Go Raw History
 1package main
 2
 3import "testing"
 4
 5func TestAlertHeadlineDropsTheTemplate(t *testing.T) {
 6	generated := "Severe Thunderstorm Watch issued September 4 at 2:54PM EDT until September 4 at 10:00PM EDT by NWS Blacksburg VA"
 7	if got := alertHeadline("Severe Thunderstorm Watch", generated); got != "" {
 8		t.Fatalf("want empty for the generated headline, got %q", got)
 9	}
10
11	written := "Flooding is expected along the Yadkin River by NWS Blacksburg VA"
12	want := "Flooding is expected along the Yadkin River"
13	if got := alertHeadline("Flood Warning", written); got != want {
14		t.Fatalf("want %q, got %q", want, got)
15	}
16}
17
18func TestAlertOffice(t *testing.T) {
19	in := "Severe Thunderstorm Watch issued September 4 at 2:54PM EDT until September 4 at 10:00PM EDT by NWS Blacksburg VA"
20	if got := alertOffice(in); got != "BLACKSBURG VA" {
21		t.Fatalf("want BLACKSBURG VA, got %q", got)
22	}
23	if got := alertOffice("no office here"); got != "" {
24		t.Fatalf("want empty, got %q", got)
25	}
26}
27
28func TestAlertAreaLeadsWithHome(t *testing.T) {
29	in := "Alleghany, NC; Ashe, NC; Caswell, NC; Rockingham, NC; Stokes, NC; Surry, NC; Watauga, NC; Wilkes, NC; Yadkin, NC"
30	if got := alertArea(in); got != "YADKIN +8" {
31		t.Fatalf("want YADKIN +8, got %q", got)
32	}
33
34	// Nowhere near home, so the first name stands.
35	if got := alertArea("Buncombe, NC; Madison, NC"); got != "BUNCOMBE +1" {
36		t.Fatalf("want BUNCOMBE +1, got %q", got)
37	}
38	if got := alertArea("Yadkin, NC"); got != "YADKIN" {
39		t.Fatalf("want YADKIN, got %q", got)
40	}
41	if got := alertArea(""); got != "" {
42		t.Fatalf("want empty, got %q", got)
43	}
44}