feat: dedupe geoip rules
This commit is contained in:
@ -31,3 +31,30 @@ func TestDedupeMatchRuleNonList(t *testing.T) {
|
||||
t.Fatalf("expected nil passthrough, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeGeoIPRule(t *testing.T) {
|
||||
rules := []interface{}{
|
||||
"GEOIP,CN,DIRECT",
|
||||
"DOMAIN,example.com,sub-a | Proxy",
|
||||
"GEOIP,CN,sub-b | Proxy,no-resolve",
|
||||
"GEOIP,JP,sub-b | Proxy",
|
||||
}
|
||||
|
||||
got := dedupeGeoIPRule(rules)
|
||||
|
||||
want := []interface{}{
|
||||
"DOMAIN,example.com,sub-a | Proxy",
|
||||
"GEOIP,CN,sub-b | Proxy,no-resolve",
|
||||
"GEOIP,JP,sub-b | Proxy",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("got %#v, want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeGeoIPRuleNonList(t *testing.T) {
|
||||
if got := dedupeGeoIPRule(nil); got != nil {
|
||||
t.Fatalf("expected nil passthrough, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user