package models import "testing" func TestSourceSupportUsesOnlyCanonicalKeyAndPersistedEnabled(t *testing.T) { yahoo := SourceYahooFinance unknown := "reuters" sources := []Source{ {ID: "supported", Type: "stocktwits", SourceKey: &yahoo, Enabled: true, ArticleLimit: 83}, {ID: "disabled", SourceKey: &yahoo, Enabled: false, ArticleLimit: 77}, {ID: "legacy", Type: "stocktwits", Name: "Yahoo Finance", Enabled: true, ArticleLimit: 42}, {ID: "unknown", SourceKey: &unknown, Enabled: true, ArticleLimit: 31}, } filtered := OperationalSources(sources) if len(filtered) != 1 || filtered[0].ID != "supported" || filtered[0].ArticleLimit != 83 { t.Fatalf("filtered=%v", filtered) } if !sources[2].Enabled || sources[2].Supported() || sources[2].Operational() { t.Fatal("legacy enabled must remain persisted, without operational support") } if !sources[1].Supported() || sources[1].Operational() { t.Fatal("disabled target support/operational mismatch") } }