package ingestion import ( "net/http" "net/http/httptest" "strings" "testing" "pete/internal/safehttp" ) func init() { // httptest servers bind to 127.0.0.1; allow the safe-dial check to // accept them in tests only. safehttp.AllowPrivate = true } func TestFetchOGImage(t *testing.T) { cases := []struct { name string body string want string // suffix match }{ { name: "og:image property", body: `
`, want: "https://example.com/lead.jpg", }, { name: "content before property", body: ``, want: "https://example.com/swap.jpg", }, { name: "twitter:image fallback", body: ``, want: "https://example.com/twit.jpg", }, { name: "relative URL resolved", body: ``, want: "/img/lead.jpg", }, { name: "no og tags", body: `Body
more