From 00247b5d87d599a96acdcfb1c84c0bf99a7ac16f Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sun, 28 Apr 2024 20:33:52 +0100 Subject: [PATCH] test: API: check empty responses Signed-off-by: Bryan Boreham --- web/api/v1/api_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 044cd171db..bb2a73f6db 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -1172,6 +1172,25 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E }, }, }, + // Test empty vector result + { + endpoint: api.query, + query: url.Values{ + "query": []string{"bottomk(2, notExists)"}, + }, + responseAsJSON: `{"resultType":"vector","result":[]}`, + }, + // Test empty matrix result + { + endpoint: api.queryRange, + query: url.Values{ + "query": []string{"bottomk(2, notExists)"}, + "start": []string{"0"}, + "end": []string{"2"}, + "step": []string{"1"}, + }, + responseAsJSON: `{"resultType":"matrix","result":[]}`, + }, // Missing query params in range queries. { endpoint: api.queryRange,