mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
Implement new function that splits filter rules
This commit is contained in:
committed by
Dan Christian Bogos
parent
40b166893a
commit
263f73283b
@@ -191,7 +191,7 @@ func splitInlineFilter(rule string) (splt []string) {
|
||||
|
||||
// NewFilterFromInline parses an inline rule into a compiled Filter
|
||||
func NewFilterFromInline(tenant, inlnRule string) (f *Filter, err error) {
|
||||
ruleSplt := strings.SplitN(inlnRule, utils.InInFieldSep, 3)
|
||||
ruleSplt := splitInlineFilter(inlnRule)
|
||||
if len(ruleSplt) != 3 {
|
||||
return nil, fmt.Errorf("inline parse error for string: <%s>", inlnRule)
|
||||
}
|
||||
@@ -335,7 +335,7 @@ func (fltr *FilterRule) CompileValues() (err error) {
|
||||
if fltr.rsrElement, err = config.NewRSRParser(fltr.Element); err != nil {
|
||||
return
|
||||
} else if fltr.rsrElement == nil {
|
||||
return fmt.Errorf("emtpy RSRParser in rule: <%s>", fltr.Element)
|
||||
return fmt.Errorf("empty RSRParser in rule: <%s>", fltr.Element)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5117,8 +5117,8 @@ func TestModelHelperAPItoFilterError(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := APItoFilter(testStruct, "")
|
||||
if err == nil || err.Error() != "emtpy RSRParser in rule: <>" {
|
||||
t.Errorf("\nExpecting <emtpy RSRParser in rule: <>>,\n Received <%+v>", err)
|
||||
if err == nil || err.Error() != "empty RSRParser in rule: <>" {
|
||||
t.Errorf("\nExpecting <empty RSRParser in rule: <>>,\n Received <%+v>", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user