RSRParser filter considering AllFiltersMatch option

This commit is contained in:
DanB
2018-07-23 04:49:48 +02:00
parent ad555cbde1
commit 2f33e0bd6d

View File

@@ -26,13 +26,14 @@ import (
func TestNewRSRParsers(t *testing.T) {
ruleStr := `Value1;Heade2=Value2;~Header3(Val3&!Val4);~Header4:s/a/${1}b/{*duration_seconds&*round:2}(b&c);Value5{*duration_seconds&*round:2}`
eRSRParsers := RSRParsers{
&RSRParser{Rules: "Value1", attrValue: "Value1"},
&RSRParser{Rules: "Heade2=Value2", attrName: "Heade2", attrValue: "Value2"},
&RSRParser{Rules: "~Header3(Val3&!Val4)", attrName: "Header3",
&RSRParser{Rules: "Value1", AllFiltersMatch: true, attrValue: "Value1"},
&RSRParser{Rules: "Heade2=Value2", AllFiltersMatch: true, attrName: "Heade2", attrValue: "Value2"},
&RSRParser{Rules: "~Header3(Val3&!Val4)", AllFiltersMatch: true, attrName: "Header3",
filters: RSRFilters{NewRSRFilterMustCompile("Val3"),
NewRSRFilterMustCompile("!Val4")}},
&RSRParser{Rules: "~Header4:s/a/${1}b/{*duration_seconds&*round:2}(b&c)", attrName: "Header4",
&RSRParser{Rules: "~Header4:s/a/${1}b/{*duration_seconds&*round:2}(b&c)", AllFiltersMatch: true,
attrName: "Header4",
rsrRules: []*ReSearchReplace{
&ReSearchReplace{
SearchRegexp: regexp.MustCompile(`a`),
@@ -43,7 +44,8 @@ func TestNewRSRParsers(t *testing.T) {
NewRSRFilterMustCompile("c")},
},
&RSRParser{Rules: "Value5{*duration_seconds&*round:2}", attrValue: "Value5",
&RSRParser{Rules: "Value5{*duration_seconds&*round:2}", AllFiltersMatch: true,
attrValue: "Value5",
converters: DataConverters{NewDataConverterMustCompile("*duration_seconds"),
NewDataConverterMustCompile("*round:2")},
},