e4774e6a06
- item 7: the storage page shows the disconnect time in local time (fmtTimeStr), not the raw RFC3339 UTC. - item 8: a disconnected drive no longer has two banners - the health check's warning for it is dropped when the dedicated alert.storage.disconnected banner was built (it stays on the wire). - item 9: alert.deadapp.group says "nezd meg" (te-form); formal ceiling 14 -> 13. - item 10: the disk/memory/CPU/temperature health banners show the dashboard's own sentence (health.* keys, hu + en) via HealthReport.WarningMsgs/IssueMsgs; the wire text is unchanged. checkResources split out of RunHealthCheck as the test seam. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
65 lines
2.6 KiB
Go
65 lines
2.6 KiB
Go
package monitor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/config"
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/system"
|
|
)
|
|
|
|
// R-516 item 10 — the resource warnings („SSD disk usage high: 90%") reached the household's banner in
|
|
// English on every page. checkResources now attaches the dashboard's own sentence (a bundle key) beside
|
|
// each one, and the wire text is byte-for-byte what it was.
|
|
//
|
|
// COMPANION RED-PROOF: give the SSD warning a zero MsgRef (addWarning) — the "warn" case fails here
|
|
// and the banner test in internal/web shows the English wire text again.
|
|
func TestR516_ResourceWarningsCarryTheirDashboardSentence(t *testing.T) {
|
|
cfg := config.Default()
|
|
cases := []struct {
|
|
name string
|
|
info system.SystemInfo
|
|
wantIssue, wantKey []string
|
|
wantWire []string
|
|
}{
|
|
{"warn", system.SystemInfo{DiskPercent: 85, HDDConfigured: true, HDDPercent: 85, MemPercent: 90, CPUPercent: 95,
|
|
TemperatureCelsius: 80, TemperatureSource: "coretemp"}, nil,
|
|
[]string{"health.system_disk_high", "health.data_disk_high", "health.memory_high", "health.cpu_high", "health.temperature_high"},
|
|
[]string{"SSD disk usage high: 85%", "HDD disk usage high: 85%", "Memory usage high: 90%", "CPU usage high: 95%", "Temperature high: 80°C (coretemp)"}},
|
|
{"critical", system.SystemInfo{DiskPercent: 95, HDDConfigured: true, HDDPercent: 96},
|
|
[]string{"health.system_disk_critical", "health.data_disk_critical"}, nil,
|
|
[]string{"SSD disk usage critical: 95%", "HDD disk usage critical: 96%"}},
|
|
}
|
|
for _, c := range cases {
|
|
r := &HealthReport{}
|
|
checkResources(r, c.info, cfg, nil, false)
|
|
texts, keys := r.Warnings, []string{}
|
|
for i := range r.Warnings {
|
|
keys = append(keys, r.WarningMsgAt(i).Key)
|
|
}
|
|
if c.wantIssue != nil {
|
|
texts, keys = r.Issues, nil
|
|
for i := range r.Issues {
|
|
keys = append(keys, r.IssueMsgAt(i).Key)
|
|
}
|
|
}
|
|
want := c.wantKey
|
|
if c.wantIssue != nil {
|
|
want = c.wantIssue
|
|
}
|
|
if len(texts) != len(c.wantWire) {
|
|
t.Fatalf("%s: %d entries %q, want %d — the cases below would be compared against nothing", c.name, len(texts), texts, len(c.wantWire))
|
|
}
|
|
for i := range texts {
|
|
if texts[i] != c.wantWire[i] {
|
|
t.Errorf("%s: the wire text moved: %q, want %q", c.name, texts[i], c.wantWire[i])
|
|
}
|
|
if keys[i] != want[i] {
|
|
t.Errorf("%s: %q carries dashboard key %q, want %q", c.name, texts[i], keys[i], want[i])
|
|
}
|
|
}
|
|
if len(r.Warnings) != len(r.WarningKinds) || len(r.Warnings) != len(r.WarningMsgs) || len(r.Issues) != len(r.IssueMsgs) {
|
|
t.Errorf("%s: the parallel slices drifted apart", c.name)
|
|
}
|
|
}
|
|
}
|