test: io.Discard logger in fix-3 tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
@@ -8,7 +9,7 @@ import (
|
||||
// fix-3: app_start_failed fires ONCE per running→down transition. down→down cycles are silent (the
|
||||
// anti-spam guarantee); down→running clears the tracker so a later re-failure re-notifies.
|
||||
func TestNotifyAppStartFailures_OneEventPerTransition(t *testing.T) {
|
||||
n := New("http://hub", "key", "cust", nil, log.New(nil, "", 0), false)
|
||||
n := New("http://hub", "key", "cust", nil, log.New(io.Discard, "", 0), false)
|
||||
var events []string
|
||||
n.pushFn = func(eventType, _, msg string, _ interface{}) {
|
||||
if eventType == "app_start_failed" {
|
||||
@@ -42,7 +43,7 @@ func TestNotifyAppStartFailures_OneEventPerTransition(t *testing.T) {
|
||||
// An app that is down on the FIRST evaluation (the F11 dead-at-boot case, after the boot grace) still
|
||||
// fires — it is a running→down transition from the tracker's empty initial state.
|
||||
func TestNotifyAppStartFailures_FirstSeenDownFires(t *testing.T) {
|
||||
n := New("http://hub", "key", "cust", nil, log.New(nil, "", 0), false)
|
||||
n := New("http://hub", "key", "cust", nil, log.New(io.Discard, "", 0), false)
|
||||
var count int
|
||||
n.pushFn = func(eventType, _, _ string, _ interface{}) {
|
||||
if eventType == "app_start_failed" {
|
||||
@@ -57,7 +58,7 @@ func TestNotifyAppStartFailures_FirstSeenDownFires(t *testing.T) {
|
||||
|
||||
// A deployed app that is up never fires.
|
||||
func TestNotifyAppStartFailures_HealthyNeverFires(t *testing.T) {
|
||||
n := New("http://hub", "key", "cust", nil, log.New(nil, "", 0), false)
|
||||
n := New("http://hub", "key", "cust", nil, log.New(io.Discard, "", 0), false)
|
||||
var count int
|
||||
n.pushFn = func(string, string, string, interface{}) { count++ }
|
||||
n.NotifyAppStartFailures([]AppRunState{{Name: "radarr", Down: false}})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
// 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 := NewAlertManager(log.New(io.Discard, "", 0))
|
||||
|
||||
am.SetDeadAppAlerts([]DeadApp{{Name: "cwa", DisplayName: "Calibre-Web", State: "stopped"}})
|
||||
got := am.GetAlerts()
|
||||
@@ -31,7 +32,7 @@ func TestDeadAppAlerts_PresentAndSelfClearing(t *testing.T) {
|
||||
// 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))
|
||||
am := NewAlertManager(log.New(io.Discard, "", 0))
|
||||
var many []DeadApp
|
||||
for _, n := range []string{"radarr", "jellyfin", "navidrome", "calibre", "seerr"} {
|
||||
many = append(many, DeadApp{Name: n, DisplayName: n, State: "stopped"})
|
||||
|
||||
Reference in New Issue
Block a user