feat: evolve rate-filter to a more generic filter

This commit is contained in:
2026-07-28 20:40:12 +08:00
parent a3e3079af1
commit b206594eb8
15 changed files with 492 additions and 193 deletions

View File

@ -3,6 +3,8 @@ package corecfg
import (
"reflect"
"testing"
"gitea.epss.net.cn/klesh/ss/internal/automation"
)
func TestPopFirstProxyGroup(t *testing.T) {
@ -72,6 +74,31 @@ func TestMergeProxySelection(t *testing.T) {
}
}
func TestRewritePoppedGroupRef(t *testing.T) {
groupRefs := []automation.ProxyRef{
{OriginalName: "Auto", DisplayName: "sub-a | Auto", Subscription: "sub-a"},
{OriginalName: "AnotherGroup", DisplayName: "sub-a | AnotherGroup", Subscription: "sub-a"},
}
got := rewritePoppedGroupRef(groupRefs)
if len(got) != 2 {
t.Fatalf("expected 2 refs, got %#v", got)
}
if got[0].DisplayName != selectionGroupName || got[0].OriginalName != "Auto" {
t.Fatalf("expected the popped group's DisplayName rewritten to %q, got %#v", selectionGroupName, got[0])
}
if got[1].DisplayName != "sub-a | AnotherGroup" {
t.Fatalf("expected the non-popped group left untouched, got %#v", got[1])
}
}
func TestRewritePoppedGroupRefEmpty(t *testing.T) {
if got := rewritePoppedGroupRef(nil); len(got) != 0 {
t.Fatalf("expected no-op on empty input, got %#v", got)
}
}
func TestMergeProxySelectionNoGroups(t *testing.T) {
combined := map[string]interface{}{"proxy-groups": []interface{}{"unchanged"}}
mergeProxySelection(combined, nil)