Skip to content

Commit 6203b55

Browse files
committed
test: add rule_filter unit test cases
1 parent 2b721d6 commit 6203b55

File tree

2 files changed

+1092
-0
lines changed

2 files changed

+1092
-0
lines changed

core/llm_token_ratelimit/rule.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type Rule struct {
2929
}
3030

3131
func (r *Rule) ResourceName() string {
32+
if r == nil {
33+
return "Rule{nil}"
34+
}
3235
return r.Resource
3336
}
3437

@@ -68,6 +71,10 @@ func (r *Rule) String() string {
6871
}
6972

7073
func (r *Rule) setDefaultRuleOption() {
74+
if r == nil {
75+
return
76+
}
77+
7178
if len(r.Resource) == 0 {
7279
r.Resource = DefaultResourcePattern
7380
}
@@ -89,6 +96,10 @@ func (r *Rule) setDefaultRuleOption() {
8996
}
9097

9198
func (r *Rule) filterDuplicatedItem() {
99+
if r == nil {
100+
return
101+
}
102+
92103
occuredKeyItem := make(map[string]struct{})
93104
var specificItems []*SpecificItem
94105
for idx1 := len(r.SpecificItems) - 1; idx1 >= 0; idx1-- {

0 commit comments

Comments
 (0)