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 "testing"
4
5// Isaac's stored preference says no closing offer of more help, the contract
6// repeats it and the final turn repeats it again. Four answers on 2026-09-08
7// still ended on one.
8func TestDropClosingOffer(t *testing.T) {
9 cases := []struct{ name, in, want string }{
10 {"a trailing offer on its own line",
11 "Sure. Here's a small sample table.\n\n| a | b |\n\nWant it wider, with more rows, or styled differently?",
12 "Sure. Here's a small sample table.\n\n| a | b |"},
13 {"an offer at the end of a paragraph",
14 "That's the whole requirement list. Want me to lay out the exact Gradle project?",
15 "That's the whole requirement list."},
16 {"a conditional offer",
17 "So the honest shape of this tool is a fetch from X's public pages. If you want, I can write it for you.",
18 "So the honest shape of this tool is a fetch from X's public pages."},
19 }
20 for _, c := range cases {
21 if got := dropClosingOffer(c.in); got != c.want {
22 t.Errorf("%s:\n got %q\nwant %q", c.name, got, c.want)
23 }
24 }
25
26 // A question the turn genuinely needs answered is not an offer, and neither
27 // is a question that is the answer.
28 keep := []string{
29 "Which of the two branches did you mean?",
30 "The trial lowered Lp(a) by 80%. So why did it fail? Because the events did not follow.",
31 "- Want: a working APK\n- Have: a Gradle project",
32 }
33 for _, k := range keep {
34 if got := dropClosingOffer(k); got != k {
35 t.Errorf("a real question was cut:\n got %q\nwant %q", got, k)
36 }
37 }
38}
39
40// The model picked the shape up from the numbered sources and filled it with a
41// name, which landed in an answer as a bracket that links to nothing.
42func TestDropLabelMarks(t *testing.T) {
43 in := "The S&P 500 is down 26.05 to 7692.55 [S&P 500]."
44 if got, want := dropLabelMarks(in), "The S&P 500 is down 26.05 to 7692.55."; got != want {
45 t.Errorf("got %q, want %q", got, want)
46 }
47 // A real citation is a number and survives, and so does a markdown link and
48 // anything inside a fence.
49 keep := []string{
50 "Novartis fell 12% on the trial result. [2]",
51 "See [the BBC piece](https://bbc.co.uk/news/1) for the detail.",
52 "```go\nrows[1] = \"x\"\n```",
53 "Use `m[\"sections\"]` to get at them.",
54 "- [x] done\n- [ ] not done",
55 }
56 for _, k := range keep {
57 if got := dropLabelMarks(k); got != k {
58 t.Errorf("something real was cut:\n got %q\nwant %q", got, k)
59 }
60 }
61}
62
63// The sidebar held "Biopharma Selloff" next to "nix config file sharing".
64func TestSentenceCaseTitles(t *testing.T) {
65 cases := map[string]string{
66 "nix config file sharing": "Nix config file sharing",
67 "Biopharma Selloff": "Biopharma Selloff",
68 "VXUS market": "VXUS market",
69 "iPhone battery life": "iPhone battery life",
70 "": "",
71 }
72 for in, want := range cases {
73 if got := sentenceCase(in); got != want {
74 t.Errorf("sentenceCase(%q) = %q, want %q", in, got, want)
75 }
76 }
77}