@@ -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 }
@@ -689,7 +689,7 @@ func TestAPIs(t *testing.T) {
689689 },
690690
691691 {
692- do : doRules (),
692+ do : doRules (nil ),
693693 reqMethod : "GET" ,
694694 reqPath : "/api/v1/rules" ,
695695 inRes : map [string ]interface {}{
@@ -784,7 +784,7 @@ func TestAPIs(t *testing.T) {
784784
785785 // This has the newer API elements like lastEvaluation, evaluationTime, etc.
786786 {
787- do : doRules (),
787+ do : doRules (nil ),
788788 reqMethod : "GET" ,
789789 reqPath : "/api/v1/rules" ,
790790 inRes : map [string ]interface {}{
@@ -888,7 +888,63 @@ func TestAPIs(t *testing.T) {
888888 },
889889
890890 {
891- do : doRules (),
891+ do : doRules ([]string {`severity="info"` }),
892+ reqMethod : "GET" ,
893+ reqPath : "/api/v1/rules" ,
894+ inRes : map [string ]interface {}{
895+ "groups" : []map [string ]interface {}{
896+ {
897+ "file" : "/rules.yaml" ,
898+ "interval" : 60 ,
899+ "name" : "example" ,
900+ "rules" : []map [string ]interface {}{
901+ {
902+ "alerts" : []map [string ]interface {}{},
903+ "annotations" : map [string ]interface {}{
904+ "summary" : "High request latency" ,
905+ },
906+ "duration" : 600 ,
907+ "health" : "ok" ,
908+ "labels" : map [string ]interface {}{
909+ "severity" : "info" ,
910+ },
911+ "name" : "HighRequestLatency" ,
912+ "query" : "job:request_latency_seconds:mean5m{job=\" myjob\" } > 0.5" ,
913+ "type" : "alerting" ,
914+ },
915+ },
916+ },
917+ },
918+ },
919+ res : RulesResult {
920+ Groups : []RuleGroup {
921+ {
922+ Name : "example" ,
923+ File : "/rules.yaml" ,
924+ Interval : 60 ,
925+ Rules : []interface {}{
926+ AlertingRule {
927+ Alerts : []* Alert {},
928+ Annotations : model.LabelSet {
929+ "summary" : "High request latency" ,
930+ },
931+ Labels : model.LabelSet {
932+ "severity" : "info" ,
933+ },
934+ Duration : 600 ,
935+ Health : RuleHealthGood ,
936+ Name : "HighRequestLatency" ,
937+ Query : "job:request_latency_seconds:mean5m{job=\" myjob\" } > 0.5" ,
938+ LastError : "" ,
939+ },
940+ },
941+ },
942+ },
943+ },
944+ },
945+
946+ {
947+ do : doRules (nil ),
892948 reqMethod : "GET" ,
893949 reqPath : "/api/v1/rules" ,
894950 inErr : errors .New ("some error" ),
0 commit comments