@@ -1054,7 +1054,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
1054
1054
params map [string ]string
1055
1055
query url.Values
1056
1056
response interface {}
1057
- responseLen int
1057
+ responseLen int // If nonzero, check only the length; `response` is ignored.
1058
1058
responseMetadataTotal int
1059
1059
responseAsJSON string
1060
1060
errType errorType
@@ -1388,17 +1388,16 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
1388
1388
labels .FromStrings ("__name__" , "test_metric2" , "foo" , "boo" ),
1389
1389
},
1390
1390
},
1391
- // Missing match[] query params in series requests .
1391
+ // Series request with limit .
1392
1392
{
1393
1393
endpoint : api .series ,
1394
1394
query : url.Values {
1395
1395
"match[]" : []string {"test_metric1" },
1396
1396
"limit" : []string {"1" },
1397
1397
},
1398
- response : []labels.Labels {
1399
- labels .FromStrings ("__name__" , "test_metric1" , "foo" , "bar" ),
1400
- },
1398
+ responseLen : 1 , // API does not specify which particular value will come back.
1401
1399
},
1400
+ // Missing match[] query params in series requests.
1402
1401
{
1403
1402
endpoint : api .series ,
1404
1403
errType : errorBadData ,
@@ -2670,18 +2669,16 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
2670
2669
"boo" ,
2671
2670
},
2672
2671
},
2672
+ // Label values with limit.
2673
2673
{
2674
2674
endpoint : api .labelValues ,
2675
2675
params : map [string ]string {
2676
- "name" : "foo " ,
2676
+ "name" : "__name__ " ,
2677
2677
},
2678
2678
query : url.Values {
2679
- "match[]" : []string {"test_metric4" },
2680
- "limit" : []string {"1" },
2681
- },
2682
- response : []string {
2683
- "bar" ,
2679
+ "limit" : []string {"2" },
2684
2680
},
2681
+ responseLen : 2 , // API does not specify which particular values will come back.
2685
2682
},
2686
2683
// Label names.
2687
2684
{
@@ -2822,13 +2819,13 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E
2822
2819
},
2823
2820
response : []string {"__name__" , "foo" },
2824
2821
},
2822
+ // Label names with limit.
2825
2823
{
2826
2824
endpoint : api .labelNames ,
2827
2825
query : url.Values {
2828
- "match[]" : []string {"test_metric2" },
2829
- "limit" : []string {"1" },
2826
+ "limit" : []string {"2" },
2830
2827
},
2831
- response : [] string { "__name__" },
2828
+ responseLen : 2 , // API does not specify which particular values will come back.
2832
2829
},
2833
2830
}... )
2834
2831
}
0 commit comments