Initial commit
This commit is contained in:
commit
66cf1fc9aa
30 changed files with 2735 additions and 0 deletions
40
checker/source_test.go
Normal file
40
checker/source_test.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue