From 6a8d2e0e3b39f84f5dba2bd31e85d9a32dda0013 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 25 Mar 2026 20:59:26 -0400 Subject: [PATCH] test: fix autocomplete test to match API response structure - Update test to unmarshal response object before extracting results array - API returns {"results": [...], "total": N}, not a bare array - Fixes "cannot unmarshal object into Go value of type []map" error - Test now correctly handles the structured autocomplete response The handleFieldValuesSearch endpoint returns a structured response with metadata (results array + total count), not a bare array. This aligns the test with the actual API response format. --- cmd/server/tests/tags_filter_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/server/tests/tags_filter_test.go b/cmd/server/tests/tags_filter_test.go index a5c5c63..fef928e 100644 --- a/cmd/server/tests/tags_filter_test.go +++ b/cmd/server/tests/tags_filter_test.go @@ -110,9 +110,11 @@ func TestTagsFilter(t *testing.T) { assert.Equal(t, http.StatusOK, rec.Code, "Should return autocomplete results") - var results []map[string]interface{} - err := json.Unmarshal(rec.Body.Bytes(), &results) + var response map[string]interface{} + err := json.Unmarshal(rec.Body.Bytes(), &response) require.NoError(t, err) + + results := response["results"].([]map[string]interface{}) assert.Greater(t, len(results), 0, "Should return 'Science Fiction' in autocomplete results") })