feat: dedupe generic rules
This commit is contained in:
@ -58,3 +58,36 @@ func TestDedupeGeoIPRuleNonList(t *testing.T) {
|
||||
t.Fatalf("expected nil passthrough, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeGenericRule(t *testing.T) {
|
||||
rules := []interface{}{
|
||||
"DOMAIN,example.com,sub-a | Proxy",
|
||||
"DOMAIN-SUFFIX,google.com,sub-a | Proxy",
|
||||
"DOMAIN,example.com,sub-b | Proxy",
|
||||
"IP-CIDR,10.0.0.0/8,DIRECT,no-resolve",
|
||||
"DOMAIN-SUFFIX,google.com,sub-b | Proxy",
|
||||
"IP-CIDR,10.0.0.0/8,sub-b | Proxy",
|
||||
"GEOIP,CN,DIRECT",
|
||||
"MATCH,sub-a | Auto",
|
||||
}
|
||||
|
||||
got := dedupeGenericRule(rules)
|
||||
|
||||
want := []interface{}{
|
||||
"DOMAIN,example.com,sub-a | Proxy",
|
||||
"DOMAIN-SUFFIX,google.com,sub-a | Proxy",
|
||||
"IP-CIDR,10.0.0.0/8,DIRECT,no-resolve",
|
||||
"GEOIP,CN,DIRECT",
|
||||
"MATCH,sub-a | Auto",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("got %#v, want %#v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDedupeGenericRuleNonList(t *testing.T) {
|
||||
if got := dedupeGenericRule(nil); got != nil {
|
||||
t.Fatalf("expected nil passthrough, got %#v", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user