fix(tags): return empty array after final pagination marker

Signed-off-by: Joonas Bergius <joonas@defenseunicorns.com>
This commit is contained in:
Joonas Bergius committed 2026-08-10 11:32:01 -05:00
1 parent 9f9289e23a
commit c36fab07fc
2 files changed
+10 -2

No files matched your search

+7 -1
View File
@@ -546,6 +546,12 @@ func TestTagsAPI(t *testing.T) {
"sb71y",
}},
},
{
name: "page after last tag",
queryParams: url.Values{"last": []string{"sb71y"}, "n": []string{"1"}},
expectedStatusCode: http.StatusOK,
expectedBody: tagsAPIResponse{Name: imageName.Name(), Tags: []string{}},
},
{
name: "page size bigger than full list",
queryParams: url.Values{"n": []string{"100"}},
@@ -601,7 +607,7 @@ func TestTagsAPI(t *testing.T) {
t.Fatalf("unexpected error decoding response body: %v", err)
}
if !reflect.DeepEqual(body, test.expectedBody) {
t.Fatalf("expected response body to be:\n%+v\ngot:\n%+v", test.expectedBody, body)
t.Fatalf("expected response body to be:\n%#v\ngot:\n%#v", test.expectedBody, body)
}
}
+3 -1
View File
@@ -79,7 +79,9 @@ func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) {
// err is either io.EOF
moreEntries = false
}
filled = returnedTags
if returnedTags != nil {
filled = returnedTags
}
}
w.Header().Set("Content-Type", "application/json")