0.2.64 update

This commit is contained in:
ponzischeme89
2026-08-15 09:23:26 +12:00
parent a2ca7e8061
commit d5d47473a2
90 changed files with 9188 additions and 451 deletions
@@ -0,0 +1,57 @@
package api
import (
"testing"
"github.com/ponzischeme89/memby/server/internal/appupdate"
"github.com/ponzischeme89/memby/server/internal/store"
)
func TestFilterClientAlertsByCategory(t *testing.T) {
prefs := store.DefaultNotificationPreferences()
prefs.SonarrAlerts = false
prefs.LibraryAlerts = false
alerts := []clientAlert{
{ID: "sonarr", Kind: alertKindSonarrAired},
{ID: "radarr", Kind: alertKindRadarrImport},
{ID: "library", Kind: alertKindLibrarySync},
{ID: "system", Kind: alertKindServerDown},
}
filtered := filterClientAlerts(alerts, prefs)
if len(filtered) != 2 || filtered[0].ID != "radarr" || filtered[1].ID != "system" {
t.Fatalf("filtered alerts = %#v", filtered)
}
}
func TestFilterClientAlertsMasterSwitch(t *testing.T) {
prefs := store.DefaultNotificationPreferences()
prefs.Enabled = false
if got := filterClientAlerts([]clientAlert{{ID: "one", Kind: alertKindRadarrImport}}, prefs); len(got) != 0 {
t.Fatalf("master switch returned %#v", got)
}
}
func TestFilterStoredSonarrNotifications(t *testing.T) {
prefs := store.DefaultNotificationPreferences()
prefs.SonarrAlerts = false
notifications := []store.UserNotification{
{ID: 1, Kind: "show-return"},
{ID: 2, Kind: "future-category"},
}
filtered := filterStoredNotifications(notifications, prefs)
if len(filtered) != 1 || filtered[0].ID != 2 {
t.Fatalf("filtered notifications = %#v", filtered)
}
}
func TestUpdatePreferenceNeverSuppressesMandatoryUpdate(t *testing.T) {
mandatory := appupdate.Decision{Status: appupdate.StatusMandatory, Version: "2.0.0"}
if got := updateDecisionForPreferences(mandatory, false); got.Status != appupdate.StatusMandatory {
t.Fatalf("mandatory update was suppressed: %#v", got)
}
optional := appupdate.Decision{Status: appupdate.StatusOptional, Version: "2.0.0"}
if got := updateDecisionForPreferences(optional, false); got.Status != appupdate.StatusNone {
t.Fatalf("optional update was not suppressed: %#v", got)
}
}