mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-28 11:02:43 +00:00
chore(lib/policy): move Checker to its own package to avoid import cycles
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGeoIPValid(t *testing.T) {
|
||||
for _, cs := range []struct {
|
||||
name string
|
||||
countries []string
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "basic-working",
|
||||
countries: []string{"US", "Ca", "mx"},
|
||||
err: nil,
|
||||
},
|
||||
} {
|
||||
t.Run(cs.name, func(t *testing.T) {
|
||||
g := &GeoIP{
|
||||
Countries: cs.countries,
|
||||
}
|
||||
err := g.Valid()
|
||||
if !errors.Is(err, cs.err) {
|
||||
t.Fatalf("wanted error %v but got: %v", cs.err, err)
|
||||
}
|
||||
if err == nil && cs.err != nil {
|
||||
t.Fatalf("wanted error %v but got none", cs.err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user