From d07142917c9be97b3602a34a5e1465bc6519603c Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 11 Feb 2026 18:16:42 -0500 Subject: [PATCH] Fix pagination test response parsing The pagination tests were incorrectly parsing the API response. The API returns data wrapped in a {"data": [...]} structure, but the tests were expecting a direct array. This caused tests to fail silently when json.Decode couldn't match the response structure. Changed response parsing to correctly extract the "data" field before asserting on array length. --- cmd/server/tests/media_item_isbn_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/server/tests/media_item_isbn_test.go b/cmd/server/tests/media_item_isbn_test.go index 69c754c..b21a5ef 100644 --- a/cmd/server/tests/media_item_isbn_test.go +++ b/cmd/server/tests/media_item_isbn_test.go @@ -334,11 +334,12 @@ func TestMediaItemsPagination(t *testing.T) { assert.Equal(t, http.StatusOK, resp.StatusCode) - var response []map[string]interface{} + var response map[string]interface{} json.NewDecoder(resp.Body).Decode(&response) + data := response["data"].([]interface{}) // Should get 2 items - assert.Equal(t, 2, len(response)) + assert.Equal(t, 2, len(data)) }) t.Run("Pagination with offset", func(t *testing.T) { @@ -352,11 +353,12 @@ func TestMediaItemsPagination(t *testing.T) { assert.Equal(t, http.StatusOK, resp.StatusCode) - var response []map[string]interface{} + var response map[string]interface{} json.NewDecoder(resp.Body).Decode(&response) + data := response["data"].([]interface{}) // Should get 2 items starting from offset 2 - assert.Equal(t, 2, len(response)) + assert.Equal(t, 2, len(data)) }) t.Run("Negative limit should fail", func(t *testing.T) {