@@ -49,6 +49,7 @@ func Test_logSelectorExpr_String(t *testing.T) {
49
49
{`{foo="bar"} |= "baz" |~ "blip" != "flip" !~ "flap" | logfmt | b=ip("127.0.0.1") | level="error" | c=ip("::1")` , true }, // chain inside label filters.
50
50
{`{foo="bar"} |= "baz" |~ "blip" != "flip" !~ "flap" | regexp "(?P<foo>foo|bar)"` , true },
51
51
{`{foo="bar"} |= "baz" |~ "blip" != "flip" !~ "flap" | regexp "(?P<foo>foo|bar)" | ( ( foo<5.01 , bar>20ms ) or foo="bar" ) | line_format "blip{{.boop}}bap" | label_format foo=bar,bar="blip{{.blop}}"` , true },
52
+ {`{foo="bar"} | logfmt | counter>-1 | counter>=-1 | counter<-1 | counter<=-1 | counter!=-1 | counter==-1` , true },
52
53
}
53
54
54
55
for _ , tt := range tests {
@@ -76,6 +77,7 @@ func Test_logSelectorExpr_String(t *testing.T) {
76
77
func Test_SampleExpr_String (t * testing.T ) {
77
78
t .Parallel ()
78
79
for _ , tc := range []string {
80
+ `rate( ( {job="mysql"} |="error" !="timeout" ) [10s] )>-1` ,
79
81
`rate( ( {job="mysql"} |="error" !="timeout" ) [10s] )` ,
80
82
`absent_over_time( ( {job="mysql"} |="error" !="timeout" ) [10s] )` ,
81
83
`absent_over_time( ( {job="mysql"} |="error" !="timeout" ) [10s] offset 10d )` ,
@@ -556,6 +558,27 @@ func Test_FilterMatcher(t *testing.T) {
556
558
},
557
559
[]linecheck {{"foo" , false }, {"bar" , false }, {"none" , true }},
558
560
},
561
+ {
562
+ `{app="foo"} | logfmt | duration > -1s` ,
563
+ []* labels.Matcher {
564
+ mustNewMatcher (labels .MatchEqual , "app" , "foo" ),
565
+ },
566
+ []linecheck {{"duration=5m" , true }, {"duration=1s" , true }, {"duration=0s" , true }, {"duration=-5m" , false }},
567
+ },
568
+ {
569
+ `{app="foo"} | logfmt | count > -1` ,
570
+ []* labels.Matcher {
571
+ mustNewMatcher (labels .MatchEqual , "app" , "foo" ),
572
+ },
573
+ []linecheck {{"count=5" , true }, {"count=1" , true }, {"count=0" , true }, {"count=-5" , false }},
574
+ },
575
+ {
576
+ `{app="foo"} | logfmt | counter <= -1` ,
577
+ []* labels.Matcher {
578
+ mustNewMatcher (labels .MatchEqual , "app" , "foo" ),
579
+ },
580
+ []linecheck {{"counter=1" , false }, {"counter=0" , false }, {"counter=-1" , true }, {"counter=-2" , true }},
581
+ },
559
582
} {
560
583
tt := tt
561
584
t .Run (tt .q , func (t * testing.T ) {
0 commit comments