feat(sources): retire Yahoo and CNBC feeds (#42)

This commit is contained in:
2026-11-25 02:00:25 +01:00
parent 7a342f240d
commit 0503c2653f
41 changed files with 603 additions and 173 deletions

View File

@ -0,0 +1,69 @@
package main
import (
"go/ast"
"go/parser"
"go/token"
"testing"
)
func TestTicket42ProductionCompositionContainsOnlyRSSAdapters(t *testing.T) {
file, err := parser.ParseFile(token.NewFileSet(), "main.go", nil, 0)
if err != nil {
t.Fatal(err)
}
found := false
ast.Inspect(file, func(n ast.Node) bool {
literal, ok := n.(*ast.CompositeLit)
if !ok {
return true
}
typ, ok := literal.Type.(*ast.MapType)
if !ok {
return true
}
value, ok := typ.Value.(*ast.SelectorExpr)
if !ok || value.Sel.Name != "Scraper" {
return true
}
found = true
if len(literal.Elts) != 2 {
t.Error("production must compose exactly two source adapters")
}
keys := map[string]bool{}
for _, element := range literal.Elts {
pair, ok := element.(*ast.KeyValueExpr)
if !ok {
t.Error("unexpected source composition")
continue
}
key, ok := pair.Key.(*ast.SelectorExpr)
if !ok {
t.Error("source must have canonical identity")
continue
}
keys[key.Sel.Name] = true
call, ok := pair.Value.(*ast.CallExpr)
if !ok {
t.Error("source must be RSS adapter")
continue
}
ctor, ok := call.Fun.(*ast.SelectorExpr)
if !ok {
t.Error("source must be RSS adapter")
continue
}
pkg, ok := ctor.X.(*ast.Ident)
if !ok || pkg.Name != "quanwenrss" || ctor.Sel.Name != "New" {
t.Error("non-RSS adapter in production composition")
}
}
if !keys["SourceBloomberg"] || !keys["SourceInvesting"] || keys["SourceYahooFinance"] || keys["SourceCNBCBusiness"] {
t.Error("production source keys do not match RSS-only policy")
}
return true
})
if !found {
t.Fatal("production source composition not found")
}
}