@@ -151,15 +151,15 @@ func TestAPIs(t *testing.T) {
151
151
}
152
152
}
153
153
154
- doLabelNames := func (label string ) func () (interface {}, Warnings , error ) {
154
+ doLabelNames := func (matches [] string ) func () (interface {}, Warnings , error ) {
155
155
return func () (interface {}, Warnings , error ) {
156
- return promAPI .LabelNames (context .Background (), time .Now ().Add (- 100 * time .Hour ), time .Now ())
156
+ return promAPI .LabelNames (context .Background (), matches , time .Now ().Add (- 100 * time .Hour ), time .Now ())
157
157
}
158
158
}
159
159
160
- doLabelValues := func (label string ) func () (interface {}, Warnings , error ) {
160
+ doLabelValues := func (matches [] string , label string ) func () (interface {}, Warnings , error ) {
161
161
return func () (interface {}, Warnings , error ) {
162
- return promAPI .LabelValues (context .Background (), label , time .Now ().Add (- 100 * time .Hour ), time .Now ())
162
+ return promAPI .LabelValues (context .Background (), label , matches , time .Now ().Add (- 100 * time .Hour ), time .Now ())
163
163
}
164
164
}
165
165
@@ -359,14 +359,14 @@ func TestAPIs(t *testing.T) {
359
359
},
360
360
361
361
{
362
- do : doLabelNames ("mylabel" ),
362
+ do : doLabelNames (nil ),
363
363
inRes : []string {"val1" , "val2" },
364
364
reqMethod : "GET" ,
365
365
reqPath : "/api/v1/labels" ,
366
366
res : []string {"val1" , "val2" },
367
367
},
368
368
{
369
- do : doLabelNames ("mylabel" ),
369
+ do : doLabelNames (nil ),
370
370
inRes : []string {"val1" , "val2" },
371
371
inWarnings : []string {"a" },
372
372
reqMethod : "GET" ,
@@ -376,31 +376,39 @@ func TestAPIs(t *testing.T) {
376
376
},
377
377
378
378
{
379
- do : doLabelNames ("mylabel" ),
379
+ do : doLabelNames (nil ),
380
380
inErr : fmt .Errorf ("some error" ),
381
381
reqMethod : "GET" ,
382
382
reqPath : "/api/v1/labels" ,
383
383
err : fmt .Errorf ("some error" ),
384
384
},
385
385
{
386
- do : doLabelNames ("mylabel" ),
386
+ do : doLabelNames (nil ),
387
387
inErr : fmt .Errorf ("some error" ),
388
388
inWarnings : []string {"a" },
389
389
reqMethod : "GET" ,
390
390
reqPath : "/api/v1/labels" ,
391
391
err : fmt .Errorf ("some error" ),
392
392
warnings : []string {"a" },
393
393
},
394
+ {
395
+ do : doLabelNames ([]string {"up" }),
396
+ inRes : []string {"val1" , "val2" },
397
+ reqMethod : "GET" ,
398
+ reqPath : "/api/v1/labels" ,
399
+ reqParam : url.Values {"match[]" : {"up" }},
400
+ res : []string {"val1" , "val2" },
401
+ },
394
402
395
403
{
396
- do : doLabelValues ("mylabel" ),
404
+ do : doLabelValues (nil , "mylabel" ),
397
405
inRes : []string {"val1" , "val2" },
398
406
reqMethod : "GET" ,
399
407
reqPath : "/api/v1/label/mylabel/values" ,
400
408
res : model.LabelValues {"val1" , "val2" },
401
409
},
402
410
{
403
- do : doLabelValues ("mylabel" ),
411
+ do : doLabelValues (nil , "mylabel" ),
404
412
inRes : []string {"val1" , "val2" },
405
413
inWarnings : []string {"a" },
406
414
reqMethod : "GET" ,
@@ -410,21 +418,29 @@ func TestAPIs(t *testing.T) {
410
418
},
411
419
412
420
{
413
- do : doLabelValues ("mylabel" ),
421
+ do : doLabelValues (nil , "mylabel" ),
414
422
inErr : fmt .Errorf ("some error" ),
415
423
reqMethod : "GET" ,
416
424
reqPath : "/api/v1/label/mylabel/values" ,
417
425
err : fmt .Errorf ("some error" ),
418
426
},
419
427
{
420
- do : doLabelValues ("mylabel" ),
428
+ do : doLabelValues (nil , "mylabel" ),
421
429
inErr : fmt .Errorf ("some error" ),
422
430
inWarnings : []string {"a" },
423
431
reqMethod : "GET" ,
424
432
reqPath : "/api/v1/label/mylabel/values" ,
425
433
err : fmt .Errorf ("some error" ),
426
434
warnings : []string {"a" },
427
435
},
436
+ {
437
+ do : doLabelValues ([]string {"up" }, "mylabel" ),
438
+ inRes : []string {"val1" , "val2" },
439
+ reqMethod : "GET" ,
440
+ reqPath : "/api/v1/label/mylabel/values" ,
441
+ reqParam : url.Values {"match[]" : {"up" }},
442
+ res : model.LabelValues {"val1" , "val2" },
443
+ },
428
444
429
445
{
430
446
do : doSeries ("up" , testTime .Add (- time .Minute ), testTime ),
0 commit comments