feat(sources): enforce supported source allowlist

Assign stable keys to the three supported sources, preserve excluded historical rows, and expose history read-only in admin. Add migration, coverage, and responsive browser spec.

Refs #13

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 00:11:26 +01:00
parent 4459a81206
commit ac17d27f51
26 changed files with 924 additions and 61 deletions

View File

@ -0,0 +1,24 @@
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")
}
}