v0.309.0: the fill warning reaches the household in its own language; the root-filesystem disk event pinned end to end (R-521 F7)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
2026-10-12 17:11:53 +02:00
parent 402fa41e45
commit 7626a28de3
14 changed files with 290 additions and 53 deletions
@@ -0,0 +1,76 @@
package fillwatch
import (
"io"
"log"
"path/filepath"
"strings"
"testing"
)
// R-521 F7 — the fill warning moved from a Go literal to the bundle (`event.fill.*`) so an English
// household is told in English. The Hungarian wire text is pinned to the byte: it is the pre-bundle
// literal (this test ran green against 68294ec's fillwatch.go with these strings carrying „Kérjük, ")
// minus that one formal opening, which the R-516 te-form gate refuses in the bundle.
func TestMessageHungarianWireText(t *testing.T) {
cases := []struct {
name string
got string
want string
}{
{"warning", Message(photos, Usage{UsedPercent: 87, AvailGB: 4.2, TotalGB: 100}, BandWarning),
"A(z) „Fotók” tároló 87% foglalt — 4,2 GB szabad hely maradt. Szabadíts fel helyet, mielőtt megtelik: törölj felesleges fájlokat, vagy csatlakoztass új meghajtót. Ha megtelik, a biztonsági mentések meghiúsulnak."},
{"critical", Message(photos, Usage{UsedPercent: 96, AvailGB: 1.4, TotalGB: 100}, BandCritical),
"A(z) „Fotók” tároló kritikusan megtelt: 1,4 GB szabad hely maradt (96% foglalt). A biztonsági mentések és az alkalmazások írásai bármikor meghiúsulhatnak. Szabadíts fel helyet mielőbb: törölj felesleges fájlokat, vagy csatlakoztass új meghajtót."},
{"terabytes", Message(Target{Path: "/mnt/big", Label: "Média"}, Usage{UsedPercent: 88, AvailGB: 2048, TotalGB: 16000}, BandWarning),
"A(z) „Média” tároló 88% foglalt — 2,0 TB szabad hely maradt. Szabadíts fel helyet, mielőtt megtelik: törölj felesleges fájlokat, vagy csatlakoztass új meghajtót. Ha megtelik, a biztonsági mentések meghiúsulnak."},
{"no label", Message(Target{Path: "/mnt/sys_drive"}, Usage{UsedPercent: 90, AvailGB: 1.5}, BandWarning),
"A(z) „/mnt/sys_drive” tároló 90% foglalt — 1,5 GB szabad hely maradt. Szabadíts fel helyet, mielőtt megtelik: törölj felesleges fájlokat, vagy csatlakoztass új meghajtót. Ha megtelik, a biztonsági mentések meghiúsulnak."},
}
for _, c := range cases {
if c.got != c.want {
t.Errorf("%s: Hungarian changed.\n got: %q\n want: %q", c.name, c.got, c.want)
}
}
}
// The household half: an English household gets the same warning in English, the built-in area named
// in English, the figure with a decimal point; a Hungarian household sends nothing extra.
func TestR521F7_HouseholdLanguageRidesTheEvent(t *testing.T) {
root := Target{Path: "/", Label: "Alkalmazások területe", LabelKey: "event.fill.label_apps"}
for _, lang := range []string{"en", "hu"} {
t.Run(lang, func(t *testing.T) {
var got []Event
w := New(filepath.Join(t.TempDir(), "s.json"), log.New(io.Discard, "", 0),
func() []Target { return []Target{root} },
func(string) *Usage { return &Usage{UsedPercent: 95, AvailGB: 3.5, UsedGB: 65, TotalGB: 68.7} })
w.SetNotify(func(e Event) { got = append(got, e) })
w.SetLang(func() string { return lang })
w.SetExtra(func(_ Target, l string) string { return "EXTRA-" + l })
if err := w.Check(); err != nil {
t.Fatal(err)
}
if len(got) != 1 {
t.Fatalf("events = %d, want 1", len(got))
}
e := got[0]
if !strings.Contains(e.Message, "Alkalmaz") || !strings.Contains(e.Message, "3,5 GB") || !strings.HasSuffix(e.Message, " EXTRA-hu") {
t.Errorf("Hungarian message = %q", e.Message)
}
if lang == "hu" {
if e.MessageHousehold != "" {
t.Errorf("a Hungarian household sends nothing extra; got %q", e.MessageHousehold)
}
return
}
for _, want := range []string{"App area", "critically full", "3.5 GB", "95%", " EXTRA-en"} {
if !strings.Contains(e.MessageHousehold, want) {
t.Errorf("English message %q lacks %q", e.MessageHousehold, want)
}
}
if strings.Contains(e.MessageHousehold, "Alkalmaz") {
t.Errorf("English message carries the Hungarian area name: %q", e.MessageHousehold)
}
})
}
}