Files
AetherForge/server/internal/alerts/evaluator_test.go
AetherForge d52479c9a6 feat: Telegram fleet alerts, forge sigil scramble, UI polish, agent ops
- Calibrate: per-event Telegram/SMTP toggles, test notification, chat ID help
- Notify on agent connect/reconnect, offline/hashrate/rejection, forge complete
- Sigil scramble post-forge uniquification and Dispense Reveal ceremony
- Full system check, desktop push, BITS/host-binary persistence, Path Tracer
- Dashboard/Crucible visual polish, haptics, sacred geometry, mobile nav
- README documents alerts, sigil scramble, and pack-usb workflow
- USB bundle repacked via pack-usb.bat (AetherForge.exe + synced agent source)
2026-06-03 20:32:59 -07:00

42 lines
992 B
Go

package alerts
import (
"testing"
"time"
"crypto-miner-server/internal/models"
)
func TestFormatPct(t *testing.T) {
if formatPct(50.55) != "50.5" {
t.Fatalf("expected 50.5 got %s", formatPct(50.55))
}
}
func TestEvaluatorOfflineAlert(t *testing.T) {
var fired []AlertEvent
e := &Evaluator{
thresholds: func() Thresholds { return Thresholds{OfflineMinutes: 5} },
settings: func() Settings { return NewSettings(NotifyConfig{}, EventToggles{AgentOffline: true}) },
broadcast: func(ev AlertEvent) { fired = append(fired, ev) },
baseline: make(map[string]float64),
lastFired: make(map[string]time.Time),
cooldown: 0,
}
agent := &models.Agent{
ID: "a1",
Name: "worker-1",
Status: "offline",
LastSeen: time.Now().Add(-10 * time.Minute),
}
e.checkOffline(agent, e.thresholds(), time.Now())
if len(fired) != 1 {
t.Fatalf("expected 1 alert, got %d", len(fired))
}
if fired[0].Type != "offline" {
t.Fatalf("expected offline alert")
}
}