controller: fix-3 dead-app alerting + fix-6 ring cap/spill/spam (WIP, pre-build)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017CDMFpFx84pfviCTVuGGhf
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// fix-3: a deployed-not-running app produces a self-clearing WARN dashboard banner; an empty list
|
||||
// clears it. COMPANION red-proof: skip SetDeadAppAlerts entirely (the pre-fix-3 silence) → GetAlerts
|
||||
// has no dead-app banner → the "not fut" assertion fails.
|
||||
func TestDeadAppAlerts_PresentAndSelfClearing(t *testing.T) {
|
||||
am := NewAlertManager(log.New(nil, "", 0))
|
||||
|
||||
am.SetDeadAppAlerts([]DeadApp{{Name: "cwa", DisplayName: "Calibre-Web", State: "stopped"}})
|
||||
got := am.GetAlerts()
|
||||
if len(got) != 1 || got[0].Level != "warning" || !strings.Contains(got[0].Message, "Telepített alkalmazás nem fut: Calibre-Web") {
|
||||
t.Fatalf("expected a WARN dead-app banner, got %+v", got)
|
||||
}
|
||||
if !strings.Contains(got[0].Message, "stopped") {
|
||||
t.Errorf("banner should carry the state: %q", got[0].Message)
|
||||
}
|
||||
|
||||
// The app recovers → an empty set clears the banner (state-based, no manual dismissal).
|
||||
am.SetDeadAppAlerts(nil)
|
||||
if got := am.GetAlerts(); len(got) != 0 {
|
||||
t.Fatalf("dead-app banner must self-clear when the app recovers, got %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Above the group threshold, many dead apps collapse to ONE grouped banner (a reboot storm must not
|
||||
// paper the dashboard).
|
||||
func TestDeadAppAlerts_GroupedAboveThreshold(t *testing.T) {
|
||||
am := NewAlertManager(log.New(nil, "", 0))
|
||||
var many []DeadApp
|
||||
for _, n := range []string{"radarr", "jellyfin", "navidrome", "calibre", "seerr"} {
|
||||
many = append(many, DeadApp{Name: n, DisplayName: n, State: "stopped"})
|
||||
}
|
||||
am.SetDeadAppAlerts(many)
|
||||
got := am.GetAlerts()
|
||||
if len(got) != 1 || !strings.Contains(got[0].Message, "5 telepített alkalmazás nem fut") {
|
||||
t.Fatalf("expected one grouped banner for %d dead apps, got %+v", len(many), got)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user