@@ -191,9 +191,9 @@ func TestAPIs(t *testing.T) {
191191 }
192192 }
193193
194- doRules := func () func () (interface {}, Warnings , error ) {
194+ doRules := func (matches [] string ) func () (interface {}, Warnings , error ) {
195195 return func () (interface {}, Warnings , error ) {
196- v , err := promAPI .Rules (context .Background ())
196+ v , err := promAPI .Rules (context .Background (), matches )
197197 return v , nil , err
198198 }
199199 }
@@ -696,7 +696,7 @@ func TestAPIs(t *testing.T) {
696696 },
697697
698698 {
699- do : doRules (),
699+ do : doRules (nil ),
700700 reqMethod : "GET" ,
701701 reqPath : "/api/v1/rules" ,
702702 inRes : map [string ]interface {}{
@@ -791,7 +791,7 @@ func TestAPIs(t *testing.T) {
791791
792792 // This has the newer API elements like lastEvaluation, evaluationTime, etc.
793793 {
794- do : doRules (),
794+ do : doRules (nil ),
795795 reqMethod : "GET" ,
796796 reqPath : "/api/v1/rules" ,
797797 inRes : map [string ]interface {}{
@@ -895,7 +895,63 @@ func TestAPIs(t *testing.T) {
895895 },
896896
897897 {
898- do : doRules (),
898+ do : doRules ([]string {`severity="info"` }),
899+ reqMethod : "GET" ,
900+ reqPath : "/api/v1/rules" ,
901+ inRes : map [string ]interface {}{
902+ "groups" : []map [string ]interface {}{
903+ {
904+ "file" : "/rules.yaml" ,
905+ "interval" : 60 ,
906+ "name" : "example" ,
907+ "rules" : []map [string ]interface {}{
908+ {
909+ "alerts" : []map [string ]interface {}{},
910+ "annotations" : map [string ]interface {}{
911+ "summary" : "High request latency" ,
912+ },
913+ "duration" : 600 ,
914+ "health" : "ok" ,
915+ "labels" : map [string ]interface {}{
916+ "severity" : "info" ,
917+ },
918+ "name" : "HighRequestLatency" ,
919+ "query" : "job:request_latency_seconds:mean5m{job=\" myjob\" } > 0.5" ,
920+ "type" : "alerting" ,
921+ },
922+ },
923+ },
924+ },
925+ },
926+ res : RulesResult {
927+ Groups : []RuleGroup {
928+ {
929+ Name : "example" ,
930+ File : "/rules.yaml" ,
931+ Interval : 60 ,
932+ Rules : []interface {}{
933+ AlertingRule {
934+ Alerts : []* Alert {},
935+ Annotations : model.LabelSet {
936+ "summary" : "High request latency" ,
937+ },
938+ Labels : model.LabelSet {
939+ "severity" : "info" ,
940+ },
941+ Duration : 600 ,
942+ Health : RuleHealthGood ,
943+ Name : "HighRequestLatency" ,
944+ Query : "job:request_latency_seconds:mean5m{job=\" myjob\" } > 0.5" ,
945+ LastError : "" ,
946+ },
947+ },
948+ },
949+ },
950+ },
951+ },
952+
953+ {
954+ do : doRules (nil ),
899955 reqMethod : "GET" ,
900956 reqPath : "/api/v1/rules" ,
901957 inErr : errors .New ("some error" ),
0 commit comments