Files
Charon/backend/internal/notifications/router_test.go
GitHub Actions 8ea907066b chore: remove Shoutrrr residue and dead notification legacy code
Remove all deprecated Shoutrrr integration artifacts and dead legacy fallback
code from the notification subsystem.

- Remove legacySendFunc field, ErrLegacyFallbackDisabled error, and
  legacyFallbackInvocationError() from notification service
- Delete ShouldUseLegacyFallback() from notification router; simplify
  ShouldUseNotify() by removing now-dead providerEngine parameter
- Remove EngineLegacy engine constant; EngineNotifyV1 is the sole engine
- Remove legacy.fallback_enabled feature flag, retiredLegacyFallbackEnvAliases,
  and parseFlagBool/resolveRetiredLegacyFallback helpers from flags handler
- Remove orphaned EmailRecipients field from NotificationConfig model
- Delete feature_flags_coverage_v2_test.go (tested only the retired flag path)
- Delete security_notifications_test.go.archived (stale archived file)
- Move FIREFOX_E2E_FIXES_SUMMARY.md to docs/implementation/
- Remove root-level scan artifacts tracked in error; add gitignore patterns to
  prevent future tracking of trivy-report.json and related outputs
- Update ARCHITECTURE.instructions.md: Notifications row Shoutrrr → Notify

No functional changes to active notification dispatch or mail delivery.
2026-03-05 00:41:42 +00:00

89 lines
2.4 KiB
Go

package notifications
import "testing"
func TestRouter_ShouldUseNotify(t *testing.T) {
router := NewRouter()
flags := map[string]bool{
FlagNotifyEngineEnabled: true,
FlagDiscordServiceEnabled: true,
}
if !router.ShouldUseNotify("discord", flags) {
t.Fatalf("expected notify routing for discord when enabled")
}
if router.ShouldUseNotify("telegram", flags) {
t.Fatalf("expected unsupported service to remain legacy")
}
}
// TestRouter_ShouldUseNotify_EngineDisabled covers lines 13-14
func TestRouter_ShouldUseNotify_EngineDisabled(t *testing.T) {
router := NewRouter()
flags := map[string]bool{
FlagNotifyEngineEnabled: false,
FlagDiscordServiceEnabled: true,
}
if router.ShouldUseNotify("discord", flags) {
t.Fatalf("expected notify routing disabled when FlagNotifyEngineEnabled is false")
}
}
// TestRouter_ShouldUseNotify_DiscordServiceFlag covers lines 23-24
func TestRouter_ShouldUseNotify_DiscordServiceFlag(t *testing.T) {
router := NewRouter()
flags := map[string]bool{
FlagNotifyEngineEnabled: true,
FlagDiscordServiceEnabled: false,
}
if router.ShouldUseNotify("discord", flags) {
t.Fatalf("expected notify routing disabled for discord when FlagDiscordServiceEnabled is false")
}
}
// TestRouter_ShouldUseNotify_GotifyServiceFlag covers lines 23-24 (gotify case)
func TestRouter_ShouldUseNotify_GotifyServiceFlag(t *testing.T) {
router := NewRouter()
// Test with gotify enabled
flags := map[string]bool{
FlagNotifyEngineEnabled: true,
FlagGotifyServiceEnabled: true,
}
if !router.ShouldUseNotify("gotify", flags) {
t.Fatalf("expected notify routing enabled for gotify when FlagGotifyServiceEnabled is true")
}
// Test with gotify disabled
flags[FlagGotifyServiceEnabled] = false
if router.ShouldUseNotify("gotify", flags) {
t.Fatalf("expected notify routing disabled for gotify when FlagGotifyServiceEnabled is false")
}
}
func TestRouter_ShouldUseNotify_WebhookServiceFlag(t *testing.T) {
router := NewRouter()
flags := map[string]bool{
FlagNotifyEngineEnabled: true,
FlagWebhookServiceEnabled: true,
}
if !router.ShouldUseNotify("webhook", flags) {
t.Fatalf("expected notify routing enabled for webhook when FlagWebhookServiceEnabled is true")
}
flags[FlagWebhookServiceEnabled] = false
if router.ShouldUseNotify("webhook", flags) {
t.Fatalf("expected notify routing disabled for webhook when FlagWebhookServiceEnabled is false")
}
}