feat: add readable routing rule comments
This commit is contained in:
1 parent
2206d03b39
commit
2fcb4ae171
4 files changed
+25
No files matched your search
@@ -69,3 +69,18 @@ func TestDisabledRuleWritesEnabledFalse(t *testing.T) {
|
||||
t.Fatalf("disabled rule: %#v", rules)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReconcileWritesRuleComment(t *testing.T) {
|
||||
config := map[string]any{"outbounds": []any{map[string]any{"tag": "proxy-a"}}}
|
||||
updated, err := reconcile(config, []Rule{
|
||||
{Name: "clash-royale", Comment: "Clash Royale", Match: map[string]any{"comment": "ignored"}, Outbound: Outbound{TagRegex: "proxy-a"}},
|
||||
{Name: "ip-rules", Outbound: Outbound{TagRegex: "proxy-a"}},
|
||||
}, "last")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rules, _ := objects(updated["routing"].(map[string]any)["rules"])
|
||||
if rules[0]["comment"] != "Clash Royale" || rules[1]["comment"] != "ip-rules" {
|
||||
t.Fatalf("unexpected comments: %#v", rules)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user