package web import ( "io" "log" "path/filepath" "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/config" "gitea.dooplex.hu/admin/felhom-controller/internal/monitor" "gitea.dooplex.hu/admin/felhom-controller/internal/settings" ) // R-79 option A (operator ruling D3, 2026-10-08) — the storage and protected-container entries of the // health check reached the banner verbatim: Hungarian for an English household (the frozen storage // formats), English for a Hungarian one (the container issue). Driven from the PRODUCER // (monitor.RunHealthCheck), not a hand-built report, so a dropped MsgRef in healthcheck.go is seen here. // Docker is refused under go test (R-650), so the Docker and protected-container issues appear on // every run of this test — that is the input, not a side effect on this host. // // COMPANION RED-PROOF: give the unavailable-path warning in checkStoragePaths a zero MsgRef — the "en" // case fails with „Adattároló nem elérhető: …". func TestR79_HealthBannersFollowTheHousehold(t *testing.T) { missing := filepath.Join(t.TempDir(), "gone") cfg := config.Default() cfg.Hub.Enabled = false cfg.Stacks.Protected = []string{"traefik"} hr := monitor.RunHealthCheck(cfg, nil, []settings.StoragePath{{Path: missing}}, settings.SMBSettings{}, nil) am := NewAlertManager(log.New(io.Discard, "", 0)) am.Refresh(hr, cfg, nil, false, "") want := map[string][]string{ "hu": {"Adattároló nem elérhető: " + missing, "Egy védett rendszerszolgáltatás nem fut: traefik", "A Docker nem érhető el: "}, "en": {"Storage not reachable: " + missing, "A protected system service is not running: traefik", "Docker is not reachable: "}, } for lang, ws := range want { var got []string for _, a := range am.GetAlerts(lang) { if strings.HasPrefix(a.ID, "health-") { got = append(got, a.Message) } } joined := strings.Join(got, "\n") for _, w := range ws { if !strings.Contains(joined, w) { t.Errorf("%s: no banner contains %q; banners:\n%s", lang, w, joined) } } } }