package checker import ( "testing" ) // TestRegisteredSourcesAreSane is a smoke test that runs over every // init()-registered source and verifies basic invariants. New sources // added later are picked up automatically. func TestRegisteredSourcesAreSane(t *testing.T) { seen := map[string]bool{} for _, s := range Sources() { if s.ID() == "" || s.Name() == "" { t.Errorf("source has empty ID or Name: %+v", s) } if seen[s.ID()] { t.Errorf("duplicate source ID: %s", s.ID()) } seen[s.ID()] = true o := s.Options() for _, f := range append(append([]any{}, toAny(o.Admin)...), toAny(o.User)...) { _ = f } } // At least the built-in sources are present. for _, want := range []string{"dnsbl", "google_safe_browsing", "openphish", "urlhaus", "virustotal"} { if !seen[want] { t.Errorf("missing built-in source %q", want) } } } func toAny[T any](in []T) []any { out := make([]any, len(in)) for i, v := range in { out[i] = v } return out }